Yolinux.com Tutorial

Clearcase Client Commands:

This tutorial covers the IBM/Rational Clearcase commands used for the Clearcase change management system.

For installation of the IBM/Rational Clearcase Client on Linux see YoLinux Clearcase Client Installation Tutorial
For Installation of the IBM/Rational Clearcase Server on Linux see YoLinux Clearcase Server Installation Tutorial


Clearcase User Commands:





Free Information Technology Magazines and Document Downloads
TradePub link image



Free Information Technology Magazine Subscriptions and Document Downloads


Environment Configuration:

Get shell config file sample from node-name:/home/vobadm/config/.bashrc, .cshrc, .kshrc.

Sample $HOME/.bashrc

export CLEARCASE=/usr/atria
...
export PATH=$CLEARCASE/bin:$PATH
...
alias ct='cleartool'
alias sv='cleartool setview'
alias svg='cleartool setview username_view'
...
MACH=`uname -n`
ID=`/usr/bin/id | /usr/bin/sed -e 's/^uid=[0-9]*(//' -e 's/).*$//'`
PS1='$MACH:($ID)$PWD> '
if [ $PS1 ]
then
if [ $CLEARCASE_ROOT ]
then
export PS1='[`basename $CLEARCASE_ROOT`]\h:(\u)\W> '
fi
fi


Sample Unix Clearcase sessions:

  • Make changes to a file:
       node-name:(username)/home/username> cleartool setview username_view
       node-name:(username)/home/username> cd /vob/vob-name/src/sub-directory
       [username_view]node-name:(username)sub-directory> ct co -nc filename.cpp
         --- edit file ---
       [username_view]node-name:(username)Directory-name ct ci filename.cpp
       Add comments here.
       .
       exit
                    
    Comments terminated with a dot (.). Use exit to get out of Clearcase view and return to Unix shell.

  • Add new file to Clearcase control:
       [username_view]node-name:(username)sub-directory> ct co -nc .
    [username_view]node-name:(username)sub-directory> cp /..../new-file ./
    [username_view]node-name:(username)sub-directory> ct mkelem -ci -nc new-file [username_view]node-name:(username)sub-directory> ct ci -nc .
    Checkout directory (.), copy file and add it to clearcase control. Then check-in directory. Directory needed updating to reflect change to its contents. Note that new files added to the directory can not be viewed by others until the directory is checked in. Example of adding all files to Clearcase control: ct mkelem -ci -nc *

  • Add new Directory to Clearcase control:
       [username_view]node-name:(username)sub-directory> ct co -nc .
    [username_view]node-name:(username)sub-directory> ct mkdir DIRECTORY-NAME [username_view]node-name:(username)sub-directory> ct ci -nc .
    ...
    Add files to directory. ... [username_view]node-name:(username)sub-directory> ct ci -nc DIRECTORY-NAME

  • Clearcase Labels:
       [username_view]node-name:(username)sub-directory> ct mklbtype -nc RELEASE_NAME_#.#.#
    (or: ct mklbtype -ordinary RELEASE_NAME_#.#.#)
    [username_view]node-name:(username)sub-directory> ct mklabel -recurse RELEASE_NAME_#.#.# .
    First command creates the label. The second applies the label to the current directory "." recursively on down the directory structure. Another example: ct mklabel -recurse -follow -nc RELEASE_NAME_#.#.# directory-name
    Where the option "-follow" allows mklabel to follow symbolic links.
    Note: Must perform the command from a directory within the VOB.

    Update a file and apply the existing label to the new file:

       [username_view]node-name:(username)sub-directory> ct mklabel -replace -nc RELEASE_NAME_#.#.# file-name@@/main/4
    Move label from version 3 and now apply it to version 4.

    Remove old label:

       [username_view]node-name:(username)sub-directory> ct rmtype -rmall lbtype:OLD_RELEASE_NAME_#.#.#

    List all labels:

       [username_view]node-name:(username)sub-directory> ct lstype -kind lbtype
    OR [username_view]node-name:(username)sub-directory> ct lstype -kind lbtype -short | sort
    OR [username_view]node-name:(username)sub-directory> ct lstype -kind lbtype -short | grep -i api | sort
    Second version lists all "API" labels.

    List all labels on a file:

       [username_view]node-name:(username)sub-directory> ct lsvtree -all file-name
                    
    Second command does not quite work (??)

    Label formats: RELEASE_NAME_#.#.#

    Default labels created by Clearcase:

    • BACKSTOP: No changes allowed. No new versions allowed when label applied. Also see "lock" command.
    • CHECKEDOUT: Currently checked out versions.
    • LATEST: Latest version of a branch.

  • Create a view:

    To find the directory used for storing views issue the following command:
       [prompt]> ct lsview
    greg_view /net/hostname/views/viewstore/greg_view.vws
    steve_view /net/hostname/views/viewstore/steve_view.vws
    ...
    Create view from views directory. Files there are viewname.vws
       [prompt]> cd /net/hostname/views/viewstore/
    [prompt]> ct mkview -tag dave_view ./dave_view.vws
    [prompt]> ct lsview | grep dave_view
    dave_view /net/hostname/views/viewstore/dave_view.vws
    [prompt]> ct describe -l /net/hostname/views/viewstore/dave_view.vws
    ...

  • Move a view:
    Assuming the move is on a single server and there are no checked out files. Stop viewserver.
    cd /net/hostname/views/viewstore/
    find view-tag.vws | cpio -pmd /destination viewstore ct rmtag -view -all view-tag ct unregister -view /net/hostname/views/viewstore/view-tag.vws
    mv view-tag.vws view-tag.vws-backup
    ct register -view /destination viewstore/view-tag.vws
    ct mktag -view -tag view-tag /destination viewstore/view-tag.vws
    ct startview view-tag rm view-tag.vws-backup

  • Clearcase Clearmake:
       [username_view]node-name:(username)sub-directory> ct lsco
    [username_view]node-name:(username)sub-directory> clearmake -C gnu -f Makefile
    [username_view]node-name:(username)sub-directory> ct catcr file.o
    One may also set the environment variable: export CCASE_MAKE_COMPAT=gnu
    Check first if there are any files checked out. Run makefile. List configuration record. The advantage of clearmake is that derived objects (object files generated by compiling source, hence derived from the source) are stored with extended names. i.e. file-name.o@@26Feb.14:28:9621


View default group on Windows PC:

  • Open a DOS command prompt window.
  • cd Program Files\Rational\Clearcase\etc\utils
  • Execute the "creds" command
  • Read the "Primary Group" domain.

PC Configspec: right click on XX: drive + clearcase + properties.

Clearcase explorer: C:\Program Files\Rational\ClearCase\bin\clearexplorer.exe


Clearcase find command:

Tag "-all" refers to all files in VOB.

  • Find all files with given label in the VOB:
    ct find -all -type file -version 'lbtype(LABEL-NAME)' -print

  • Find all new or changed files since that with a specified label:
    ct find -all version '\!lbtype(LABEL-NAME) && version(/main/LATEST)' -print

  • Find all files at the end of a branch in current directory:
    ct find ./ -version 'version(.../branch-name/LATEST)' -print


Explanation of Clearcase views and file structure within a view:

Views are required in order to use Clearcase. A unique view assigned to a user will:

  • allow a developer access to the VOB data (source code storage)
  • provide a workspace are where users can privately modify VOB data without disturbing the view of the VOB data held by other developers. Changes are only accessible by others when a file is checked into the VOB from the users private space.

There are three types of views:

  • Snapshot view: Changes and updates by others are not available to a snapshot view until a new "snapshot" is taken.
  • Web view: accessible from Clearcase Web interface. Similar to a snapshot view.
  • Dynamic view: access to all versions of VOB elements and view private objects as they are checked into the VOB.

Directory Structure within view:

The Clearcase view and versioning system is based on a directory structure beneath what at first appears to be a standard set of files in a directory structure.

Example: (set view first: ct setview xxxxxx)

Clearcase presentation Unix presentation
ct ls
    filename1.ext@@/main/3                        Rule: /main/LATEST
filename2.ext@@/main/6 Rule: /main/LATEST
ls
    filename1.ext
    filename2.ext
    
Note that there are three versions of the file in the main branch.

Actual Directory path representation:

filename1.ext@@/              - Actually a directory name not a file name
               LABEL-1       - Actualy a file with the full contents.
               LABEL-2
               main/         - Directory of main branch.
                    LABEL-1  - Actual file with full contents of file.
                    LABEL-2  - Actual file with full contents of file.
                    0        - Actual file containing version zero.
                    1        - Actual file containing version 1
                    2        - Actual file containing version 2
                    3        - Actual file containing version 3
                    LATEST   - Actual file with full contents of file.
                
Note:
  • Clearcase stores the full contents of the file saved and not a diff between versions like RCS or SCCS which builds versions of the file when neccessary.
  • The file "3" and "LATEST" are identical.
        cd filename.ext@@/main
    diff 3 LATEST
    This will show no change between the files.
  • Search all archived files for a string:
    find filename.ext@@ -print grep 'wordToFind' {} \;
This knowledge can facilitate searches in previous versions of source code.

Relationship between views and directory structure:

Each view will have the directory structure described above within its view.
/view/...                             - View root directory
/view/view-name1/
bin/... - Entire OS file system viewed from here for view-name1 etc/.. .../... vob/vob-name/src/filename1.ext - Unix presentation or filename1.ext@@ for "ct ls" .../... - Contents of Clearcase VOB /view/view-name2/
bin/... - Entire OS file system viewed from here for view-name1 etc/.. .../... vob/vob-name/src/filename1.ext .../... - Contents of Clearcase VOB
  • This path /view/... is viewable by the regular UNIX user, with or without setting the view.
  • When you set your view ("ct setview view-name1"), it allows one to view the Clearcase archive from /vob/vob-name/....
  • The above path is for /view/view-name1/
  • The path /view/view-name1@@/ will show all the revision branches. i.e.
    /view/view-name1@@/vob/vob-name/main/LATEST/directory-name/main/LATEST/...
    0/...
    0/...
    1/...
    2/...
    1/...


Configspec:

Configspec specifies rules of viewing specified elements which will be shown in a given view. The system default configspec can be found in $ATRIAHOME/default_config_spec (Typically: /usr/atria/default_config_spec)

Basic configspec:
(/destination viewstore/view-tag.vws/config_spec)

element * CHECKEDOUT
element * /main/LATEST

Pattern matching:

Pattern Description
* Matches all elements in the path but not recursively.
*.h Matches all elements in the path which match the suffix ".h", but not recursively.
src/Makefile Matches all elements in the path in a directory named "src" which match this file name.
src/.../Makefile Matches all elements in the directory/subdirectory tree named "src" which match this file name.
src/.../*.[ch] Matches all elements with the suffic ".h" and ".c" in the directory/subdirectory tree named "src".
src/... Matches all elements (files and directories) in the directory/subdirectory tree named "src".

Config Rule Description
element * CHECKEDOUT This rule is mandatory. Without this rule, any file that is checked out will not be seen in a view.
element -directory * /main/LATEST Look at latest version of the directory on the main branch.
element -directory * /branch-name/LATEST Look at latest version of the directory on the defined branch.
element -file * /main/version-number Show this particular version number of all fields in view.
element * LABEL Show elements with this label. (i.e. element * /main/LABEL3)
element * rule-name -time time
element * rule-name -time 26-Oct.14:32
Show elements which comply with this rule and last modified prior to time
element * rule-name -time time Show elements which comply with this rule and last modified prior to time
element * /vob/vob-name/AppName/* LABEL Show elements in the specified directory with the given label.
element /vob/projectA/... /main/LATEST Rule applies only to specified directory hierarchy.


Branching:

Branching can be performed to:

  • Allow parallel development between two developers and later merge the code.
  • Create a new version of the software with different features for a specific purpose.
  • Add features in a separate branch to be merged in later after it is proven. The benefit is to allow the main branch to continue without being disturbed.

Configspec to view branch:

element * CHECKEDOUT
element * .../branchx/LATEST
element * /main/LATEST -mkbranch branchx
This configspec will create a new branch for new files added or for files checked out. If file is checked out from /main/LATEST, then trigger (mkbranch branchx) executes to create a new branch for the file checked out.

The branch type must first be created with the command: mkbrtype -c "Comment goes here" branchx


Create the branch type before creating the actual branch. Only one branch type of a given name will exist. Many files may exist with the branches of the same branch type.

Example of creating a branch:

  • ct mkbrtype -c "Comment goes here" BugFix_branch_Y
  • ct setview view-name
  • ct mkbranch -nc BugFix_branch_Y file-to-branch.cpp
This will create version "0" of file-to-branch.cpp in the branch named BugFix_branch_Y.

Create a branch off of version 5 of file-to-branch.cpp in branch main.
ct mkbranch -nc BugFix_branch_Y file-to-branch.cpp@@/main/5

Create branch using all source: ct mkbranch -nco -c "Bugfix patch B" patch_B *.cpp *.h
GUI: ct lsvtree -g file-name

Merging: If one wishes to include the changes made in a branch into the "latest" version in the "main" branch, one would perform a "merge".

  • Merge version 5 on the branch into the "latest" version in the "main" branch:
    ct merge -to file-to-merge.cpp -insert -version /main/BugFix_branch_Y/5

  • Specify consecutive versions 2 through 5:
    ct merge -t file-to-merge.cpp -insert -version /main/BugFix_branch_Y/2/main/BugFix_branch_Y/5

  • Merge all changes in a branch into the "main" branch:
    ct findmerge file-to-merge.cpp -fversions .../BugFix_branch_Y/LATEST -merge

List all branches: ct lstype -kind brtype


GUI Tools:

Tools:

  • xclearcase:
    Command: /usr/atria/bin/xclearcase
  • xcleardiff:
    Command: /usr/atria/bin/xcleardiff
    Motif resource file: (Add to $HOME/.Xdefaults)
    xcleardiff*promptBrightColor:   yellow
    xcleardiff*changeColor: blue
    xcleardiff*deleteColor: red
    xcleardiff*insertColor: green
  • xlsvtree:
    Command: /usr/atria/bin/xlsvtree
[Potential Pitfall]: You may have to issue the command export LANG=C prior to launching GUI.

Common resources:
Motif resource file: (Add to $HOME/.Xdefaults)

*scheme:              Monet
*XmText*marginHeight: 4
*foreground: black - Text color *background: white


Version String Generation:

  • Makefile:
    ...
    target: version.h $(OTHER_OBJS)
    cc -o target -DDATE ="\"@(#)`date`\"" $(OTHER_OBJS)
    ...
  • Source Code: (.h file)
    ...
    char *version = "@(#)target R3.0";
    char *version_time = DATAE;
    ...

This is used in conjunction with the UNIX what command. (Not available on Linux)


Notes:

  • Users of UNIX sysV systems may find that they can't print using the "lp" command as the spooler can't locate the file if it does not operate with the users view. Use the command "lp -c file-name" which creates a copy which the spooler can read.
  • Applications spawned from scripts are not able to process Clearcase controlled files. Raw executables can. When working with HTML files I can use the konqueror browser but I have not had any luck running Mozilla which is spawned from a shell script.


Links:


Books:

Software Configuration Management Strategies and IBM(R) Rational(R) ClearCase(R) : A Practical Introduction
by David E. Bellagio, Tom J. Milligan
ISBN #0321200195, IBM Press May 23 2005

Amazon.com
The Art of ClearCase(R) Deployment : The Secrets to Successful Implementation
by Christian D. Buckley, Darren W. Pulsipher
ISBN #0321262204, Addison-Wesley Professional (July 13, 2004)

Amazon.com
Software Configuration Management Strategies and Rational ClearCase: A Practical Introduction
by Brian White
ISBN #0201604787, Addison-Wesley Professional; 1st edition (August 25, 2000)

Amazon.com
YoLinux.com Home Page
YoLinux Tutorial Index
Privacy Policy | Advertise with us | Feedback Form |
Unauthorized copying or redistribution prohibited.

Bookmark and Share

Copyright © 2004, 2005, 2006 YoLinux.com