Rational ClearCase commands

1. Introduction

Rational 'ClearCase' aka 'Cleartool', is a powerful, elegant version control system. Since it's heritage is Unix, the manual is ... obscure. These battle tested commands should get you up and running...

 

ClearCase Commands : Basics 

01. To get help

DOS bigots will appreciate the intuitive nature of the Unix equivalent of 'Help': 'man' (aka Manual Pages)

To get help on the entire command set enter:
cleartool man

To get help on a specific command enter:
cleartool man command
(eg: cleartool man co for help on the checkout command)




02. To enter Cleartool

cl<return>
The prompt will change to cleartool.




03. To exit Cleartool.

exit<return>
or
quit<return>





04. To navigate inside Cleartool

Use the standard cd or cd .. commands to navigate the directory tree.



Warning! Be aware that if you exit from Cleartool back to the shell after having moved around in the directory tree within Cleartool, that you will NOT be returned to the directory that you were in when you entered Cleartool from the shell.

The pwd (present working directory) command can help you keep track of where you are.



05. To enter graphics mode (slow but gorgeous).

cl xlsvtree filename
or
xcleartool

The xlsvtree graphics viewer is a powerful tool for viewing the version tree of a file. It is very useful for visual diffing of one version of the file against another, labelling versions or moving labels around.



ClearCase Commands : File Checkin Checkout 

06. To check out a file.

cleartool checkout file.ext
or
cl co file.ext
cl co -c "comment" file.ext

End comment with: <ret>.<ret>or <ctrl><d>

Cleartool will prompt for a comment if you do not use the third format to supply one.

Although you may not be used to providing a description of the changes at checkout time ot is good practice to enter the reason you are checking out the file.

Other team members can then see who has the file out and why.

When you check the file back in this text will be presented as the default ci change description, which you can override. If you are forethoughtful about the comment most often it will not need to be re-typed when you do the checkin.

The file checked out stays in the same directory but the permission changes from read only to read/write.



07. To cancel a checkout.

cl unco file.ext


 

08. To check out a previous version of a file.

This should be:
cl co file.ext@@/main/version#>
and it is a defect in the tool that this command is not implemented.

Instead, you will have to do a tap dance to get the version you want in your view:

#1. cl co file.ext

#2. cl exit to return to the shell

#3. pwd to make sure you are in the right directory at the shell level. If not, navigate to the right directory.

#4. cp file.ext/main/version# tmpfile.ext

You can then change tmpfile as required, cp/copy it to the atria directory with the correct name, enter cleartool again and check the file in. Exit cleartool to the shell to rm/delete the temporary file. Using a tmp_name will help ensure that you don't screw up and delete the atria archive file by mistake!





09. To find what you have checked out.

cl lsco -me -all

Remember to do this at the end of your session to make sure you have not forgotten to check back in files and directories.

Other team members cannot access the files for update until you have checked them back in, and will have to waste time diffing and merging your changes with theirs if they are forced to use private copies.





10. To find out what other files are checked out.

cl lsco -all


 

11. To check in a file.

cleartool checkin file.ext
or
cl ci -c "comment" file.ext

Cleartool will display the comment you entered at co time as the default. You may override this if you want to.

End comment with <ret>.<ret> or <ctrl>-d

Do NOT use -nc which means no comment.
Comment your versions!!!!



12. To checkin or checkout multiple files.

To check in, or check out multiple files at once with the same comment:

cl ci -c "comment" *
cl co -c "comment" *

 

ClearCase Commands : Labels

13. To list existing labels.

cl lstype -lbtype




14. To observe the naming conventions for branches and labels.

branch names: all lower case eg: forwarding, ip, gap

LABELS : ALL UPPER CASE eg: BETA_2.5, PRE_GAP_MERGE




15. To Make a label.

cl mklbtype BETA_1.1B

Note: The convention for labels is as above: all caps.




16. To label a version of a file.

cl mklabel -c "comment" -rec x.

Warning! Do not confuse these foolishly named operations:
mklbtype makes (creates) a new label.
whereas
mklabel ATTACHES the label made by mklbtype to a specific file.




17. To apply a label to the entire source tree.

This is typically done for alpha, beta, final releases so that the entire set of files with the label can be built.

#1 Use 'catcs/edcs' (Tip 43) to set up your configspec with
element * MyLabel
element * /main/LATEST

#2 mklbtype MyLabel and enter appropriate comments.

#3 Be in the top level (/src) directory.
To apply the label throughout the tree:
mklabel -recurse -c "X Release" MyLabel .
Wait a long time.




18. To move an existing label down to the latest elements.

mklabel -recurse -replace MY_LABEL

will move existing label MY_LABEL down to the latest revision of each file in the directory, and below, from which you invoke this command.

'replace' is a poorly named option: it really means 'move-down'.




19. To see if a label is on the latest version of a file or on a branch.

cl find -version 'lbtype(LABELNAME) && version(/main/LATEST)' -print
or
cl find . -version 'version(/main/LATEST) && ! version(/main/GAP)' -print

You can do lots of mix and match to find what you want.


ClearCase Commands : File and Version Information 

20. To change the comment for a revision.

Many revision control tools won't let you change a comment once committed, on grounds of theology (Tichy didn't permit it), or control freakieness (typically MIS installations).

Cleartool is realistic, and accomodating, so you have a chance to correct and revise comments as needed.

chevent -c "comment" -rep file.name@@/main/version#
will replace an existing comment for revision n on the main trunk.

chevent -c "comment" -rep *
will replace the existing comments on the latest revisions of all files in the current directory.




21. To change the content description for a file.

When you set up a file initially on atria with -mkelem, you can use the -c "comment" qualifier to record a description of the contents of the file.

To change this subsequently:

chevent -c "content description" -rep file.ext@@/main/version#



22. To list the history (versions with comments) of a file.

cl lshist -all -since 08:00 file.ext

will list all changes made to the file since the time specified.



23. To Find out what files have been worked on since a given date.

It is sometimes very useful to get a list of all the changes made to the source tree since a given date.

cl lshist -all -since 31-Jul-96.23:59 



24. To find out the file_type of a file.

This is useful to confirm that a file is stored by Cleartool in an appropriate format.

Element type : Use with
text_file : Flat ascii text file
file : Any binary file that you don't mind Cleartool compressing for storage.
compressed_file : Binary file that's already compressed and you want Cleartool to store as-is.

To find this out enter:
describe file.ext
or
describe *



25. To setup cleartool to send email on a file change.

You may want to cause e-mail to be sent to email handle 'supercon' when a particular file has been updated.

This is particularly useful, for example, if you have patched the source in a commercial library and you want to be sure that when the library is upgraded your changes do not get overwritten, as the newest version of the library may or may not have corrected the error your patches peviously corrected.

The e-mail notification acts as a helpful reminder to re-test for the bug which was encountered in the earlier version, and re-update and re-build the commercial library if the library vendor did not fix the problem.

How to do it:

#1: Get VOB access.

#2: Create an e-mail notification script in unix format and add it to atria. For example:
Courtesy aric kollmyer:#!/bin/sh
mailx -s "Cleartool warning: Reminder on zLib update" supercon
ENDMAIL New Version of dialog.cpp
create: $CLEARCASE_PN by:
$CLEARCASE_USER Comment string:
-------------
Someone has really done it now, they installed a new version of zLib!.
This may cause problems as I made the following patches to :
dialog.cpp in the zDialogFrame::create() method to correct .....
So, you had better re-test with the new zApp libraries linked in and
verify that trhe new library fixes this problem
-Me Self (555) 123-4567 Quincy, CA meself@hotmail.com
ENDMAIL

#3: Register the script file as a trigger.
cl mktrtype -nc -element -postop checkout -exec
<nameAndFullPathOfScriptFile> <nameOfTrigger>

Example:
cl mktrtype -nc -element -postop checkout -exec
/gl/vobs/netman/src/zapp/source/glenayre.sh glenTrigger

#4: Attach the trigger to an existing element:

cl mktrigger -nattach <nameOfTrigger> <nameOfElementToAttachItTo>

Example:

cl mktrigger -nattach glenTrigger dialog.cpp

The examples shown will send e-mail document to supercon when dialog.cpp is checked-out.
 
ClearCase : Directory Operations

26. To add a new directory to the source tree.

Again a multi part operation as, to achieve transparency, directories are themselves vob (versioned) objects.

#1 First checkout the directory under which you want to create the new sub-directory.
cl co -c "Add directory xxx" .

The period indicates that you are checking out a directory.

#2 mkdir xxx

#3 Give the new directory privilege level 775
cl protect -chmod 775 .

#4 To verify the privilege level is 775
ls -adl .

The directory attribute string should be: d rwr rwr r-x (7 7 5)

These last two steps will ensure that someone else can later manipulate the directory without having to come back to you to beg for the privilege!




27. To rename a directory in the /gl/vobs/netman/src tree.

Eg: /src/ui/thunk_ar

#1 Change to the directory you want to rename eg: /ui/thunk_ar and check it out:
cl co .

#2 Checkout the directory above the directory you want to rename : eg /ui
cl cd..
cl co .

#3 Rename the directory by mv'ing it:
cl mv thunk_ar thunk_31

#4 Check in the directories:
cl ci .
cl cd thunk_31
cl ci .





28. To rename a vob directory or element.

Checkout the directory that contains the directory or element to be renamed.
Do
cl mv oldname newname
for the directory or element. Check it in.
 
ClearCase Commands : File Add Move Rename 

29. To Add a new file to an existing directory.

This is multi part operation as to achieve transparency, cleartool directories are themselves versioned. So ...

#1 First, you have to checkout the directory, because adding a file will change the directory. Enter a checkout comment which can also serve as the check in comment later.

cl co -c "Add file xxx" .

The period indicates that you are checking out a directory.

#2 Make an (empty) file 'element'

cl mkelem -c "file description" file.ext

NOTE! This assumes that the new element has an extension that is known to Cleartool. If not, and you get a gobbledegook message 'Cant pick element type from...' then you must specify an element type eg:

cl mkelem -c "Config stuff" -eltype text_file cb.cfg

The file types are:


text_file
: Flat ascii text file
file
: Any binary file that you don't mind Cleartool compressing for storage.
compressed_file
: Binary file that's already compressed and you want Cleartool to store as-is.

#3 Copy the source code to the new file.

#4 Checkin the file. This will be the first revision.
cl ci -c "comment" file.ext

#5 Check the directory back in.
cl ci .

The default comment you supplied in #1 above sbould be ok.

#6 You should check that you have set up the file with an apppropriate storage type. See: Tip 24 'To find out the file type of a File'.




30. To use symbolic links avoid duplicating an archive file in different directories.

Suppose we have directory A with archived file.ext eg: /../VOBS/.../A/file.ext and we want to have the same file in Directory B.

Rather than duplicate the file, we can place a link in directory /../VOBS/.../B to point to the 'real' archive file in directory A.

To setup the link:

*
Change to the B directory



*
Checkout the B directory: cl co -c "Link to file A" .



*
Change to the A directory



*
Enter: cl ln -slink /../vobs/.../A/file.ext /../vobs/.../B



*
Change to the B directory and do a ls -al to inspect the links.






31. To move an atria file from one directory to another.

Check out the source directory :
co .

Check out the target directory :
co .

In the source directory type :
mv file.ext /gl/vobs/netman/src/etc/etc/newfile.ext




32. To make a view private copy of a file.

co -unreserved




33. To Cleartool 'rm' an atria archive file.

First enter the ClearCase tool:

cl

Once INSIDE the ClearCase tool
rm filename

This will remove the archive from the view, but it is still accessible and can be viewed or retrieved if you need it again at some later time.

Warning! If you use rm filename outside Cleartool ie at the shell level the file is GONE!




34. To look at a file that has been Cleartool 'rm'd'.

more .@@/main/5/file.ext@@/main/LATEST

Replace '5' with the last version of the directory that contained the file.

Instead of more you can use less - see man less for info.




ClearCase Commands : Branches

 
35. To list existing branches.

cl lstype -brtype




36. To Make a branch.

#1 cl mkbrtype Eagle
and enter appropriate comments (doesn't matter where in the tree you are).

#2 mklbtype Eaglebase and enter appropriate comments.

#3 Be in the top level (/src) directory.
mklabel -recurse Eaglebase .
to apply the label throughout the tree.
Wait a long time.






#1 Use 'catcs' (Tip 23 : Look at your configspec) to ensure that your view is currently set to the main line.

#2 Change the directory to the root of the source tree.

#3 Label the entire source tree PRE_WHATEVER_MERGE so that if you screw up big time it'll be easier for people to check out files bsu.

#4 cl findmerge . -fver /main/BRANCH_NAME -merge -xmerge

This command will, for all the files on the branch:

*
present side-by-side Mainline-Branch-FinalMerged windows for all non-trivial merges back to the mainline.



*
Check out the file, and put the contents of the FinalMerged window in it.



*
Create a matching file.contrib file.

We're not going to try and verify the merge here and now. Click 'y' to accept the generated merge files, until all the files are processed.

#5 In the root directory you will find a FILExxxx log, listing all the files merged. Print it.

#6 Using the log printout as a control:

*
Use xlsvtree or something equivalent to diff the checked out file against the predecessor file on the main-line.



*
Verify the merged file is the way you want it and edit it if not.



*
Build the app to verify the changes are (syntactically) valid.



*
Regression testing the app would be nice.



*
Checkin the verified files to the mainline.



*
- rm the file.contrib files. Try not to rm the file object by mistake.

#7 Note! There is no such thing as a valid merged .dlg file!

Bring up the latest mainline and latest branch .dlg files in a resource editor and hand tool the changes!




ClearCase Commands : Releases



38. To build a release.

#1 Use catcs / edcs to set up your configspec with
element * LabelToBuildFrom

#2 IMPORTANT! Make sure that you have commented out with the '#' symbol:
#element * /main/LATEST

Failure to do this will mean that later file versions updated AFTER the labelled versions will get into the build!




39. To obtain a directory listing of the source tree for a release.

#1 Use Tip 13 command to get a list of existing labels.

Write down the label for the release you want eg 'RELEASE_2.02'.
Get it right!

#2 Use Tip 43 to add this line to your configspec:
element * RELEASE_2.02
before the existing:
element /gl/vobs/netman/src/docs/.../main/LATEST
element * main/LATEST

Save the configuration, exit, and reply yes to confirm the configspec change.

#3 Open /install/bmp/splash.bmp or title.bmp in PaintBrush to confirm that the configspec change has worked and you are accessing the source version you require.

#4 Do a:
dir s: /s > release.xxx
to do a recursive directory listing of the s: source drive using the view set by the new configspec, and pipe the result to a file.

#5 Don't forget to change your configspec back to normal!



40. To obtain a list of file changes since the last release.

This is useful when you want to do a code review prior to a new release.

In the directory at the top of the src tree:

find . -version 'version(/main/LATEST)
&& !lbtype(RELEASE_3.0)' -exec 'echo $CLEARCASE_PN >> pooh.bar'

This will recursively examine the source tree and output to pooh.bar a list of the files with head versions with no label ie the changes since the last label was applied to all the files.


ClearCase Commands : Administrator 

41. To remove (destroy) the latest version(s) of a file.

Warning! Don't do this without being sure you know what you are doing!

This command will chop off the latest version from a file, including versions above it if the version is not the latest one!
rmver file.exe@@/main/version#




42. To look at your configspec.

catcs

This will display the directives that Cleartool is currently using to filter files into your logical 's:' drive. eg:

# Setup to access the main branch
element * /main/LATEST

#Setup to build an entire labelled version
#and ONLY files labelled this way
#element */main/LATEST

must be commented out
#or files added/changed later than this will get included in the build
#element *RELEASE_3.01

# Setup to access the tigger branch
# element * /main/tigger/LATEST
# element * /main/tiggerBase -mkbranch tigger
# element * /main/LATEST -mkbranch tigger



43. To change your configspec.

Edcs
[End Document]