views:

37

answers:

2

In a ClearCase config spec, is it possible to select versions based on element attributres (not version attributes)? For instance:

element * ...{SOME_ELEM_ATTR==SOME_VALUE&&lbtype(MY_LABEL1)}

This doesn't work because the last part of the "element" spec is a version-selector, which only looks at version attributes.

What I'm trying to do is partition my files into two or more classes, and have different "element" lines apply to different classes of files. I tried tagging all the elements in one class with an attribute, but hit a dead end with trying to base the selection on that in the config spec. The only way I can see to do this sort of thing is to put all the files of one class in one place and use the second construct (the "pattern") to differentiate:

element .../all_class1_files/... MY_LABEL1

but this is really ugly because you have to move all the files of one class into one place, or have a giantic config spec listing all the individual directories and/or files.

Thanks in advance...

Ray

A: 

One first solution would be to replace the attribute criteria by a branch.
That way, you would more easily be able to label all files from one branch or another, instead of "all files with a given attribute".

Other than this workaround, you will find some find command based on attribute here (or in the man page).
You could then combine a find query with an "-exec" directive to put the label that you want.
That way, you don't have to mess with the config spec syntax (which may not support the exact selection criteria you are after).


I didn't test it, but you could try

element * ...{SOME_ELEM_ATTR==SOME_VALUE && lbtype_sub(MY_LABEL1)}

, because lbtype_sub is an element, branch and version selector (whereas lbtype is just a version selector).
However, since lbtype doesn't seem to be part of the config spec criteria, I doubt it can work in said config spec.

VonC
Thanks, I appreciate your help, VonC. Selecting by branch will work, but it is complicated due to the large number of branches involved. Using "find" to tag the files is not a viable option, because this would have to be done every time a version is created. But I think I may be onto a good solution using the "trtype" query function.
Ray Balogh
@Ray: interesting. If you have a viable solution, you can post it here (and select it as the official solution if you want)
VonC
A: 

I think I've up with a good solution using "trtype" as a selection criterion (appears to be the only query function that inherits from the element to the version). If the Class1 and Class2 elements have dummy triggers Class1Files andClass2Files attached to them, respectively, then something like

element * .../{trtype(Class1Files)&&lbtype(MY_LABEL1)}
element * .../{trtype(Class2Files)&&lbtype(MY_LABEL2)}

should do the trick. This selects files in Class1 with MY_LABEL1 and in Class2 with MY_LABEL2. I haven't actually tried this out yet, but I'll let you know how this works out.

Ray Balogh