Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

how to find all the labels for a given file in clearcase

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

For a version of a file, you can:

 cleartool descr -fmt "%l
" /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 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...