command in clearcase to get list of all labels app

2019-02-20 05:31发布

问题:

I'm trying to get the list of all the labels applied on an element.

I'm using

cleartool desc <element>

This seems to list all the other details of the element as well. Is there any particular option with desc command that lists only labels?

Thanks

回答1:

Use cleartool fmt_ccase in order to restrict the describe to only the labels.

cleartool descr -fmt "%l" myFile

You can see that technique used in:

  • "Which tag or branch is created from a particular branch"
  • "Command to find labels applied on particular branch"
  • "Cleartool - List Objects with Their Labels"

For instance, a slightly more complete output would be:

cleartool descr -fmt \"%n labels:%l\n\" myFile

Note: in UCM, a cleartool lsbl would be enough (for listing baselines).
But for base ClearCase, cleartool descr works.



回答2:

To get labels for all versions of the element, add '-version' and a query to get all versions. My example uses !lbtype(x), since all our versions do NOT have the label 'x'.

cleartool find . -version "!lbtype(x)" -name "yourelement" -exec "cleartool descr -fmt \"%n labels:%l\n\" \"%CLEARCASE_XPN%\""

To output list with space separation, change the -fmt to -> -fmt \"%Nl \". List could be very long if there are lots of versions and labels.



回答3:

If you are using dynamic views, you can also use extended naming to see the set of labels applied to versions of the element:

% ls myfile.c@@

Note that the output also includes the 'main' branch. You can omit the branch(es) on a non-directory element simply:

% ls -1F myfile.c@@ | grep -v /

Extra credit - You can also use extended names to see the set of labels applied to versions of a particular branch:

% ls -1F myfile.c@@/main/mybranch | grep -v / | grep '[A-Za-z]'

(the trailing 'grep' assumes labels have at least one alphabetic character and will omit version numbers that would otherwise also be included in the output.) That output will also include 'LATEST' but you can easily omit that, too, if desired.



标签: clearcase