copy file versions from ClearCase using cleartool find on UNIX or Linux

You can copy certain versions out of your view to the local filesystem using command line operations.

If the element version that you want to copy is selected by the view's config spec, then the copy can be completed using the operating system (OS) copy command.

Here is the syntax using the OS copy command:

cp


However, if the version of interest is not selected by the config spec, then you will need to construct a
cleartool find syntax as the find command is not limited by the view's config spec.


Using
cleartool find will allow you to copy files that are not selected by the view you are using.

Note: The source version must be selected by its version extended pathname.

The copy operation will need to rename the version extended pathname to the original element name, because the OS copy command considers the last part of the version extended pathname to be the element's true name.

Example:

%>cp file.txt@@/main/3 /export/home/user/file.txt

Note the rename from file.txt@@/main/3 to file.txt

%>cd /export/home/user

%>ls
file.txt


For the copy to work correctly on the versions that are not selected by your view, you need to copy the files using the environment variable (EV), CLEARCASE_XPN.

To counteract the OS copy behavior of preserving the version extended pathname, you can use CLEARCASE_PN to strip the leaf name of the element version, which will capture the correct target.


The following find command example will locate the file and specific version in the VOB and copy it to your location of choice:


Example:


cleartool find . -exec 'cp -p $CLEARCASE_XPN /tmp/$CLEARCASE_PN'


CAUTION: You will see unexpected results if running this find command from a snapshot view because of a known behavior difference with how snapshot view render path delivered by the CLEARCASE_XPN variable versus how dynamic views render the paths.

A snapshot view will provide a path which is will contain the snapshot view path followed by the VOB tag path followed by the actual filename and path below the VOB tag root.

A dynamic view will provide will simply show the VOB path followed by the actual filename and path below the VOB tag root.

Example:

Snapshot View Output from CLEARCASE_XPN

/export/home/snapshots/view_1/vobs/vob1/dir1/file

is returned from a snapshot view instead of...


Dynamic View Output from CLEARCASE_XPN


/vobs/vob1/dir1/file

No comments:

Post a Comment