tags:

views:

199

answers:

1

I know one awkward solution for this taks will be :

  • first use ct ls to get the entire version info of the file
  • and pipe the version info to a parsing script to actually get the labels of the file .

But I guess ClearCase should have a "build in" solution for this task without support from any external scripts.

Please help me if you happen to know a "build in" solution for the task.
Thanks in advance.

+1  A: 

fmt_ccase contains all the format-string for various ClearCase elements.

For a version of a file, you can:

 cleartool descr -fmt "%l\n" /path/to/a/version

%l
Labels: For versions, all attached labels; the null string otherwise.
Labels are output as a comma-separated list, enclosed in parentheses.
A <SPACE> character follows each comma.

Variants:

  • %Cl
    Max labels: Specify the maximum number of labels to display with the max-field-width parameter (see Specifying field width).
    If there are more labels, "..." is appended to the output.
    If no max-field-width is specified, the maximum default value is 3.
  • %Nl
    No commas: Suppress the parentheses and commas in label list output;
    separate labels with spaces only.

So the result can be:

Labels: (Rel3.1C, Rel3.1D, Rel3.1E)
Labels without commas or parens: Rel3.1C Rel3.1D Rel3.1E

In both case, you still need to parse the result, but at least the output can contain only the labels, as in:

Rel3.1C Rel3.1D Rel3.1E

onaclov2000 adds (from the comments):

The only problem with this is that you are grabbing the label on the specific version of the file.
Given that branches etc can exist, we'll need to be able to get ALL labels on a file.
If you use version tree graphical and select tools -> "locate" you can see ALL the labels attached to that file.
Is there a common command in cleartool that will return the results of "locate", or "contents"?

The lsvtree (graphical version tree) does display the labels of all the versions of the element currently seen by the view when you click "Label Name"

That being said, there does not seem to be a "built-in" solution and some parsing is involved:

For instance (which is a bit shorter than the OP version but still based on a cleartool ls):

ct ls -l addon.xml@@|grep version|gawk "{gsub(/^version.*@@\\\\/,\"\",$0) ; gsub(/ \ [.*/,\"\",$0); print $0}"

(GnuWin32 syntax)

or, only with a dynamic view:

cd m:/myView/path/to/addon.xml@@
# list all files, not directories: the files are the labels
dir /B /A-D 
VonC
The only problem with this is that you are grabbing the label on the specific version of the file, given that branches etc can exist, we'll need to be able to get ALL labels on a file, if you use version tree graphical and select tools -> "locate" you can see ALL the labels attached to that file, is there a common command in cleartool that will return the results of "locate", or "contents"?
onaclov2000
@onaclov2000: not sure about the downvote, but I have extended my answer to address the "list all labels" query.
VonC