Search code examples
clearcase

ClearCase: Find all versions of a file newer than labelled version


Suppose I have a file with versions 0 to 4. On version 2 I applied a label called mylabel. Now I want to do a find query using cleartool which gives me all versions created after my labelled version 2. That is I only want to get versions 3 and 4 as output, but not versions 0-2.

I know how to find all versions except the labelled one:

cleartool find . -version "!lbtpye(mylabel)" -print

There is also a command to get the history of this element:

cleartool lshistory -minor PATH_TO_FILE

This theoretically gives me the date when the label was applied, so I could do

cleartool find . -version "created_since(date)" -print

But the lshistory command always outputs the full history of the element and I feel it is too much to parse all this information just to get the desired date.

So basically I want to know if there is a more elegant way to do this. I could imagine that I could maybe first check which version has mylabel (because the version number is already provided by the find query) and then search for files with a version higher than the labelled version. So in my example with mylabel at version 2 I would hope for something like:

cleartool find . -version "version( > /main/2)" -print

After VonC's answer I should mention that the labeltype will only be created once and the label itself moved every few days. It is therefore not possible to check for the time the labeltype was created.


Solution

  • version( > /main/2) jas no equivalence in the ClearCase config spec 'version selectors'.

    That means an easier option should rely on a convention, like the convention the date of applying the label should be very close to the date of creating the label type.
    Meaning the mklbtype shoudl be done just before mklabel, and you could then use the label type creation date for your cleartool find . -version "created_since(date)" -print query.

    Basically, the crux of the issue is to keep track of the date where the label where last applied (or moved, since it is here a shifting label).

    Another approach would be to store that date as an attribute attached to the lbtype: only one lbtype, and one attribute changed each time the label is moved.
    See cleartool mkattr.