Tuesday, December 8, 2009

Clearcase Cheat Sheet

Build Security Manager

cleartool mkview -tag mwview mwview.vws
clearmake -V -C gnu -f makemgr DEBUG='-g'

Create a symlink.

cd /vobs/folder
cleartool checkout subfolderThatWillContainSymlink
.
cd subfolderThatWillContainSymlink
cleartool ln -slink /path/to/real/file nameOfNewSymlinkAtCurrentLocation
cd ../
cleartool checkin subfolderThatWillContainSymlink
.

Delete a symlink.

cd /vobs/folder
cleartool checkout subfolderThatContainsSymlink
.
cleartool rm subfolderThatContainsSymlink/symLink
cleartool checkin subfolderThatContainsSymlink
.

Create a view on Unix. Select it. Show its config spec. Change its config spec.

cd /viewstore
cleartool mkview -tag yourView yourView.vws
cleartool setview yourView
cleartool catcs
cleartool edcs

Other useful commands on unix.

cleartool diff -pre myfile.cpp

Write a new config spec with private branch by hand. This doesn't work unless the "branch type" already exists (see below).

element * CHECKEDOUT
element * ...\my_private_branch\LATEST
mkbranch my_private_branch
element * \main\LATEST
element * \main\0

Windows example of creating the "branch type". You might have to do this on all vobs from which you plan to checkout.

cd /d "X:/my_vob"
cleartool mkbrtype -nc my_private_branch

To get help, use the man command which will open some html served locally.

cleartool man

To remove a file from a view (it still exists in clearcase) you use the rmname command. The folder must already be checked out.

cleartool rmname myfile.cxx

To restore a deleted file (i.e. undo rmname) you need to know the branch and version of the folder that contained the file. You can find this from the version tree.

In the following example we go to the directory that contained the file. Check-out the current directory as unreserved with no comment. Create a link at the current location to the branch and version of the directory that contained the file. And keep the original name (via .). Last we checkin the current directory with no comment

cd /yourVob/yourFolder/
cleartool checkout -unr -nc ./
cleartool ln .@@/main/yourBranch/123/yourFile.cpp .
cleartool checkin -nc ./

To move a file from one place to another, you use the mv command.

cleartool mv myfile.cxx somewhere\myfile.cxx

To add a new file to source control, you use the mkelem command. Here's an example in unix.

cd /vobs/myvob/myfolder
cleartool checkout -unr -nc mysubfolder
cd mysubfolder
cleartool mkelem myexistingfile.cxx
.
cleartool checkin myexistingfile.cxx
<your comments here>
.
cd ../
cleartool checkin mysubfolder
.

To see the difference between two versions of a certain file:

cleardiff \myvob\myfolder\myfile.cxx@@\main\mybranch\2 \myvob\myfolder\myfile.cxx@@\main\anotherbranch\3

To get/set permission info for a file in clearcase:

Z:\myvob\myfolder>cleartool describe -long myfile.exe

version "myfile.exe@@\main\1"
created 2009-03-30T13:45:41-04 by Michael Holtstrom (myname.mygroup@mymachine)
"checkin comments"
Element Protection:
User : DOMAIN\myname  : r--
Group: DOMAIN\mygroup : r--
Other:                : r--
element type: compressed_file
predecessor version: \main\0
Attributes:

Z:\myvob\myfolder>cleartool protect -chmod 755 myfile.exe

To get help:

cleartool man

For a given view, what are the versions of a certain set of files?

Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -cvi -print
.           All elements in and below the current directory [Z:\myvob\myfolder]
-nr         Don't recurse. Only look at elements within this directory.
-type f     Only look at elements that are of type file (i.e. not directories, not symlinks)
-name sk*.h Only look at files whose names start with 'sk' and end with '.h'
-cvi        Display the version that is currently selected by this view.
-print      Print the result-set to screen

Same as above but the search location is explicitly specified.

Z:\>cleartool find "Z:\myvob\myfolder" -nr -type f -name sk*.h -cvi -print

For a set of files, find those that are on a certain branch and report the version selected by this view:

Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -branch "brtype(mybranch)" -cvi -print
-branch "brtype(mybranch)" == First eliminate all versions of selected elements that *aren't* on branch 'mybranch'
-cvi == Then from the remainder, only keep the versions that are currently selected by this view.

See above for meaning of [ . -nr -type f -name sk*.h -print ]

For a set of files, find those that aren't on a certain branch and report the version selected by this view:

Z:\myvob\myfolder>cleartool find . -nr -type f -name sk*.h -branch "!brtype(main)" -cvi -print
-branch "!brtype(main)" == First eliminate all versions of selected elements that *are* on branch 'main'
-cvi == Then from the remainder, only keep the versions that are currently selected by this view.

See above for meaning of [ . -nr -type f -name sk*.h -print ]

Find all files of a certain type in a certain location:

Z:\>cleartool find "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -name *.h -cvi -print
"Z:\myvob\myfolder" "Z:\myvob\another" == All elements in and below these directories [Z:\myvob\myfolder], [Z:\myvob\another]
-name *.h == Only look at files whose names end with '.h'

See above for meaning of [ -nr -type f -cvi -print ]

Find all files from a set of types/extensions in a certain location:

Z:\>cleartool find "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -name *.[tch]* -cvi -print
-name *.[tch]* == Only look at files whose names contain '.t' or '.c' or '.h' (i.e. '.txt', '.cpp', '.cxx', '.c', '.h')

See above for meaning of [ "Z:\myvob\myfolder" "Z:\myvob\another" -nr -type f -cvi -print ]
{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "Examples and common commands for the Clearcase version control system.", "page": { "blogIds": [ 26 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }