1

Using cleartool on a bash command line, I'd like to find for a given element, all the versions numbered 0, whichever the branches holding them.

The problem is that, as far as I can say, the "cleartool find" command requires at least specific branch-name in its version-selector:

=> This works: cleartool find MyElem -version "version(.../MyBranch/0)" -print

=> Whereas this doesn't: cleartool find MyElem -version "version(.../0) -print

The only solution I've got so far is to parse the version tree. It works but it is quite slow when ran on a long list of elements: cleartool lsvtree -all -s MyElem | grep -e '/0$'

Does anyone know a smarter solution?

Many thanks in advance.

JNM
  • 125
  • 9
  • It would help to know WHY you are looking for the /0 versions. Literally EVERY branch instance will have a /0 version. Are you looking for branches where /0 is the ONLY version on the branch? – Brian Cowan Nov 28 '19 at 03:40

2 Answers2

0

A 0 version is is a placeholder version created for any new element added to source control.

But the a version selector, even with ellipsis wildcard '...' must include a branch.

Since all branches are derived from main/, check if this would work:

cleartool find MyElem -version "version(/main/.../0)" -print

If not, a variation of your first cleartool find solution would be one I mention in "Clearcase finding a specific file on any branch":

cleartool find -all -name "MyElem" -ver "! lbtype(<non-existing label>)" -print

This should print all versions if a file "MyElem", across branches.
You can grep for the '/0' version.
But that might end up being as slow as the lsvtree.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Many thanks for your answer, but "/main/.../0" doesn't work (it is seen as a malformed branch pathname) and as you assumed, using "find" instead of "lsvree" is not faster. – JNM Nov 29 '19 at 08:19
  • @JNM That is what I thought. I never seen a "fast" solution with ClearCase. Listing the branch in general should be a good start. – VonC Nov 29 '19 at 08:20
0

In the even that you're looking for branches where the /0 version is the latest on the branch, try:

cleartool find -ver "version(.../MyBranch/0) && version(.../MyBranch/LATEST)" -print

I think you can find those versions for a lot of branches using:

cleartool lstype -kind brtype -short | while read i; do
    cleartool find -ver "version(.../$i/0) && version(.../$i/LATEST)" -print
done

What you do with those versions is up to you. Be aware that you may not want to just erase these willy-nilly as a cascading -mkbranch rule set may create /main/foo/0 as a parent of /main/foo/bar/0. If you were to remove the former branch, you would also either remove or require removal of the latter, which may not be what you want. (the rmbranch man page will tell what you need to know about whether rmbranch will remove child branches....

Brian Cowan
  • 1,048
  • 6
  • 7
  • Thank you for your suggestion, but scanning all the brtypes makes the process even slower. – JNM Nov 29 '19 at 08:25
  • if you have a list of target branches, you can use that. Since we don't know the business problem driving the question it's a bit of a challenge to offer tailored alternatives – Brian Cowan Nov 30 '19 at 14:39