ClearCase: find files that have only one specific label and no more

I would like to find files in ClearCase that are tagged with a specific label, but have no other labels .

For example, if I have files marked as follows:

file1 LBL_A, LBL_B
file2 LBL_A

I would like to have a query that only gives me file2, not file1.

Is there a way to do this with cleartool find? If this cannot be done with a single request, I will also be happy for any ideas on how to do this in a few steps (I will call cleartool from the perl script, so it will be easy to save the file lists temporarily and run additional commands on them).

Many thanks!

Jan

+5
source share
3 answers

, LBL_A (),

cleartool find /some/dir -version 'lbtype(LBL_A)' -print | xargs cleartool describe -fmt "%n: %l"

file1: (LBL_A, LBL_B)
file2: (LBL_A)

, perl script sed -n 's/\(.*\): (LBL_A)/\1/p' ( ).

: VonC, , , . :

cleartool find ... -print | tr '\012' '\000' | xargs -0 cleartool ....

ascii null, xargs .

+6

, :

cleartool find . -ver "lbtype(LBL_A) && !lbtype(LBL_B)" -print
+5

hlovdal answer , , , ( ClearCase ).

:

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -print

( , ). -version , .

fmt_ccase , , perl script :

 cleartool find . -type f -element 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%En %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","
  • -fmt "%En %l\n" ( :/a/b/myFile @@/main/myVersion) => /a/b/myFile'. the '\n` .
  • -version -fmt "%n %l\n"
  • \"$CLEARCASE_XPN\": , , .
  • grep -v ",": - , " "
  • %Cl: . , , !

So, to find the exact version :

 cleartool find . -type f -version 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%n %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","|awk '{sub(/ \(.*/,"");print}'

Note:
The above works with unix syntax. Window Syntax:

cleartool find . -type f -element "lbtype(LBL_A)" -exec "cleartool describe -fmt \"%n %Cl\n\" \"%CLEARCASE_XPN%\"" | grep -v "," | gawk "{gsub(/ \(.*,"");print}"

in which the version of files with only one (correct) label will be displayed.

  • awk '{sub(/ \(.*/,"");print}'converts " myFile@@/main/myVersion (LBL_A)" to "myFile @@ / main / myVersion"
+2
source

All Articles