开发者

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 fro开发者_Python百科m any external scripts.

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

Thanks in advance.


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 


The IBM article "Additional examples of the cleartool find command" is a great source for find query.
To expand on the "lsvtree" bit mentioned by VonC in his answer, you have:

To find all elements with any label:

Windows:

cleartool find . -type f -exec "cleartool lsvtree -a %CLEARCASE_PN%" | findstr
"("
./hello.c@@/main/1 (LABEL100, LABEL99, LABEL98, LABEL97)
./foo.xml@@/main/BR1/1 (REL2)
./bar.o@@/main/1 (REL1)

UNIX/Linux:

cleartool find . -type f -exec 'cleartool lsvtree -a $CLEARCASE_PN' | grep "("

./hello.c@@/main/1 (LABEL100, LABEL99, LABEL98, LABEL97)
./foo.xml@@/main/BR1/1 (REL2)
./bar.o@@/main/1 (REL1)

That finds only labels for versions currently selected in the view, but you could reuse the lsvtree part to grep all versions of a file with labels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜