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

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.

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.

Related

How to find activities of a modified files in Clearcase

I have a file test.cpp somebody added a few lines of code i don't know when but i'm assuming it was in a specific range of time that i know.I want to find the activity that was used to deliever this changes, i found a lot of versions of this element in the version tree of this element, but all the activities that i was able to see were as a result of a rebase, i need to find the source activity that was in charge of adding this few lines of code.
Is there any way to do that ?
For each deliver activity (that you can see in the version tree), you can list the contributing activities with
cleartool lsact -contrib activity:anact#/apvob # on unix #/vobs/apvob
See "Finding which developer activities were delivered in a specific delivery"
Then you need to describe each activity found, to see if your file is in it.
cleartool descr -l activity:anact#/avob
Obviously, you also can use a cleartool annotate, in order to see the versions in that file: see "How to use ClearCase Annotate".
If you see one line which interest you, check its version n# 'x' and use cleartool descr -l file#/main/.../x to find its corresponding activity.

In ClearCase using commandprompt, how to check whether we have checkedout the latest version of the file?

I have a file called prog.c in clearcase, for example the user has checked out this file, say the user has checked out the version 3 of the file.
After that, if some other users checked in the same version of file. say the latest version be 6.
How to check the latest version of the file using the CLEARTOOL command?
One way would be a cleartool lsvtree yourFile:
That would display a textual representation of the version tree, allowing you to see if the version you have is the LATEST on a given branch.
But one nice trick I sometime use in snapshot view is: 'cleartool co -nc yourFile'.
if it works, I cleartool unco immediately.
but, if the version isn't the LATEST, the checkout will fail, with a warning asking to update first.
Note that in a dynamic view, the problem is slightly different: one can checkout (unreserved) while other checkout/check-in.
You will know you don't have the LATEST version on the checkin stage: it will complain you must merge with the actual latest version in order to create a "new latest" version which will the the result of the combination (merge) of your work and the later versions.
One way to know where your at, with a checked out version, is to do a:
cleartool descr -pred -fmt "%Sn" MyFile
(see "Change set predecessor using cleartool", and "How to list all my check-ins using ClearCase?")
"%Sn" will give you the branch and version of the file currently checked out.
You can compare that with:
cleartool descr -fmt "%Sn" M:\aDynamicView\Vob\path\to\myFile
If you have a dynamic view with the same config spec and no checkouts, you can use it as "reference view", and see if the branch version in that reference view is the same than the version previous to the one checked out in your local (snap or dyn) view.

How to find files or elements which are not modified after a paticular version in ClearCase

How to find files or elements which are not modified after a paticular version in ClearCase?
Like I want to find all the elements which were not modified after version 1(no versions after version 1).
Or Can we find all the elements which are not modified after a particular date in ClearCase?
As explained in "Find files in Clearcase view newer than a specific date?", you can find files newer (since then), not before.
That means you would need to:
find all files
find those with version post a certain date
deduce the resulting group of files by removing the second set from the first.
Regarding version, you can try and find all files without version 2, for instance:
cleartool find . -version 'version(.../bugs/2)' -print
But remember, a version can be deleted, and a file would still have a version 3, 4... so it is not a guarantee.

clearcase query results into winmerge

I can compare two files in Winmerge by triggering a comparison on the command line with a command similar to:
WinMergeU C:\file1.txt C:\file2.txt
I can query a list of files with particular properties in clearcase with a clearcase query similar to:
Y:\VOB_A>cleartool find . -type l -exec "cleartool describe -fmt "%n %[slink_text]Tp\n\n\" \"%CLEARCASE_PN%\""
.\Directory\createsymlink.txt -->..\..\VOB_B\SymlinkFolder\createsymlink.txt
What I want is to generate a set of clearcase query results that can then be used as input to winmerge (ie generate a bunch of diff commands on checkins fulfilling a certain criteria like user or day).
How can I write a clearcase query to get a list of file elements (referable in clearcase ie winmerge could open the path to the version on a dynamic view), and get their corresponding previous version of the file?
The bit to format this to winmerge I imagine would look somewhat like this:
... describe -fmt "WinMergeU ...
One, you would need to generate the right full extended pathname for each file (one being the result of your query, one being the previous version of the one found by said query)
Two, you need to do so in a dynamic view (in order to access to any version though the extended path name of the file.
Once your query gives you a version, you can ask, with a cleartool descr -fmt "%PSn" (see fmt_ccase man page), for the previous version and add that to your result file.
Trying to do it all in one pass (find + predecessor version + WinMerge call) seems too complicated.

clearcase latest version of a file on a particular branch

I know the filename of a clearcase versioned file. How can i find the latest version of this file on a particular branch ? It should not pick any child branches. Also the parent branch names may not be know always.
Thanks.
If you are using a dynamic view, you can directly access the LATEST version of a given branch by using the extended path:
cat file##/main/branch/subbranch/LATEST
If you don't know the exact branch path (parent branches) this version is stored in, you can modify your dynamic view and add first the selection rule
element /path/to/file .../subbranch/LATEST
That will select the LATEST version of subbranch within the dynamic view.
Or you can do a cleartool find, in order to see the full extended path for that file:
cleartool find . -name "yourFile" -ver "version(.../subbranch/LATEST)
You will be able to cat (or type in Windows) directly the result (which will be the full extended path)
The diea behind the cat or the cleartool find is to be able to use the syntax .../subbranch/LATEST.
That syntax with the three dots means: '.../subbranch' whatever branches followed by /subbranch.

Resources