Clearcase

While using the Rational Clearcase version control system, I have got used to several aliases and created several scripts to simplify certain commands.

  • Avoid ClearCase warning: Missing charsets in String to FontSet conversion
    Put the following in your local profile:
    export LC_CTYPE=C

    In case this doesn't work, try setting

    export LC_ALL=C
  • Use vim as editor for 'ct edcs' etc.
    Put the following in your local profile:
    export EDITOR=vim
    export WINEDITOR=vim
  • Clearcase aliases
    alias ct='cleartool'
    alias vt='ct lsvtree'
    alias d='ct describe'
    alias cmake='clearmake -C gnu'
  • dif: graphical diff with previous version
    Usage: dif [element]
    #!/bin/sh
    $(which cleartool) diff -pre -g $@ &
  • lb: describe one or more labels
    Usage: lb [label1] [label2] ...
    #!/bin/bash
    $(which cleartool) desc ${*/#/lbtype:}
  • rmview: remove a view
    Usage: rmview [viewname]
    #!/bin/sh
    CT=$(which cleartool)
    $CT endview $1
    $CT endview -server $1
    $CT rmview -tag $1
  • lsbr: list all files on a specified branch
    Usage: lsbr [branch-name]
    #!/bin/sh
    if [ -z "$1" ]; then
    	echo "Usage: `basename $0` branchname"
    	exit
    fi
    $(which cleartool) find -branch "brtype($1)" -all -nxn -print
  • lsco: list checked-out files, with optional filter
    lscov: list checked-out files in all vobs, with optional filter

    Usage:
    • lsco [optional search-term]
    • lscov [optional search-term]

    Note: lscov should be a symbolic link to the lsco script
    Tip: I often use the following command to list all checked-out files in the current directory:

    • lsco `pwd`
    #!/bin/sh
    CT=$(which cleartool)
    
    if [ `basename $0` == "lscov" ]; then
    	OPTIONS="-cview -avobs -short"
    	SORT=cat
    else
    	OPTIONS="-cview -a -short"
    	SORT=sort
    fi
    
    if [ -z "$1" ]; then
    	$CT lsco $OPTIONS | $SORT
    else
    	$CT lsco $OPTIONS | grep "$1" | $SORT
    fi
    
  • lsview: list all views with your username, with an optional filter
    lsviewa: list all views, with an optional filter

    Usage:
    • lsview [optional search-term]
    • lsviewa [optional search-term]

    Note: lsviewa should be a symbolic link to the lsview script

    #!/bin/sh
    CT=$(which cleartool)
    OPTIONS="-short"
    GREPSTR="cat"
    
    if [ `basename $0` == "lsviewa" ]; then
    	GREP="grep $1"
    else
    	GREP="grep $USER"
    	[ ! -z "$1" ] && GREPSTR="grep $1"
    fi
    
    $CT lsview $OPTIONS | $GREP | $GREPSTR | sort
  • moddiff: graphically compare two labels
    Usage: moddiff [optional path] [label1] [label2]
    #!/bin/sh
    CT=$(which cleartool)
    
    if [ -z "$1" -o -z "$2" ]; then
    	echo "Usage: `basename $0` [path] label1 label2"
    	exit;
    fi
    
    if [ -z "$3" ]; then
    	path=.
    	label1=$1
    	label2=$2
    else
    	path=$1
    	label1=$2
    	label2=$3
    fi
    
    f1=`mktemp /tmp/${label1}___XXX`
    f2=`mktemp /tmp/${label2}___XXX`
    
    (
    	$CT find $path -ver "version($label1)" -pri >$f1 2>/dev/null
    	$CT find $path -ver "version($label2)" -pri >$f2 2>/dev/null
    	$CT diff -g "$f1" "$f2" 2>/dev/null
    	rm $f1 $f2
    ) &