Wednesday, September 10, 2008

Baseline vs. Label

When comparing elements or versions in UCM, many people use baseline the same way as label in Base ClearCase. For example, to find out all elements changed between two version, use the command:

cleartool find -all -element '{lbtype_sub($LABEL1) && lbtype_sub($LABEL2)}' -version '{(lbtype($LABEL1) && ! lbtype($LABEL2)) || (lbtype($LABEL2) && !lbtype($LABEL1))}' -print

Full baseline name can be used to substitute the LABEL1 and LABEL2 variable in the command in UCM.


However, baselines are different from labels. A full baseline labels every elements in the stream, no matter they are visible or not; while label only applies to visible elements selected by the view. This implies that you cannot use two baseline names to find out which elements have been deleted (renamed) between two baselines. The following command will fail to give out the removed files.

cleartool find . -element 'lbtype_sub($BASELINE1) && !lbtype_sub($BASELINE2)' -print

If you have labeled every elements selected by the two baselines respectively, you can get deleted files by command:

cleartool find . -element 'lbtype_sub($LABEL1) && !lbtype_sub($LABEL2)' -print