I would like to get the date when a label was created.
The command below does list the labels, but all of them. I would like to only get the date associated with a specific label.
cleartool lstype -kind lbtype -invob $(cygpath -wa $VIEWDIR)
And if possible without extensive use of grep or sed to extract the information.
For a given lbtype, you can use the cleartool describe command:
cleartool descr lbtype:MYLABEL#/vob/myvob
Combined with fmt_ccase, you can limit to only the date
cleartool descr -fmt "%d" lbtype:MYLABEL#/vob/myvob
This gives the creation date of the label type (not when a label was set to a version)
cleartool desc -fmt %d LABEL#\VOB
Related
I'm trying to get the list of all the labels applied on an element.
I'm using
cleartool desc <element>
This seems to list all the other details of the element as well.
Is there any particular option with desc command that lists only labels?
Thanks
Use cleartool fmt_ccase in order to restrict the describe to only the labels.
cleartool descr -fmt "%l" myFile
You can see that technique used in:
"Which tag or branch is created from a particular branch"
"Command to find labels applied on particular branch"
"Cleartool - List Objects with Their Labels"
For instance, a slightly more complete output would be:
cleartool descr -fmt \"%n labels:%l\n\" myFile
Note: in UCM, a cleartool lsbl would be enough (for listing baselines).
But for base ClearCase, cleartool descr works.
To get labels for all versions of the element, add '-version' and a query to get all versions. My example uses !lbtype(x), since all our versions do NOT have the label 'x'.
cleartool find . -version "!lbtype(x)" -name "yourelement" -exec "cleartool descr -fmt \"%n labels:%l\n\" \"%CLEARCASE_XPN%\""
To output list with space separation, change the -fmt to -> -fmt \"%Nl \".
List could be very long if there are lots of versions and labels.
If you are using dynamic views, you can also use extended naming to see the set of labels applied to versions of the element:
% ls myfile.c##
Note that the output also includes the 'main' branch. You can omit the branch(es) on a non-directory element simply:
% ls -1F myfile.c## | grep -v /
Extra credit - You can also use extended names to see the set of labels applied to versions of a particular branch:
% ls -1F myfile.c##/main/mybranch | grep -v / | grep '[A-Za-z]'
(the trailing 'grep' assumes labels have at least one alphabetic character and will omit version numbers that would otherwise also be included in the output.) That output will also include 'LATEST' but you can easily omit that, too, if desired.
In ClearCase suppose I have a branch App_Feb_Branch. Now I want to know if any Tag or Label has been created from this branch. How can I get this information?
You can list baselines (for ClearCase UCM) or grep for version with a label (for base ClearCase).
See "Command to find labels applied on particular branch":
ct find . -nrec -name "." -ver "brtype(myBranch)" -exec "cleartool descr -fmt "%l" \"%CLEARCASE_XPN%\""
With fmt_ccase formatting options, you can use the %l to only display labels for the versions found.
That is what the cleartool descr -fmt "%l" \"%CLEARCASE_XPN%\" part of the cleartool find above does.
I have two similar but different config specs that I believe should select all of the same element versions. How can I most easily check if this is the case?
You can create two dynamic views, each one with their own config spec:
cleartool setcs -tag aViewTag yourConfigSpecFile
You can then compare the result of:
cleartool ls
(in both views)
A cleartool ls display the exact version found in each view.
Even better, using fmt_ccase:
# unix
cleartool find . -exec 'cleartool desc -fmt "Version: %n\n" $CLEARCASE_XPN'
#windows
cleartool find . -exec "cleartool desc -fmt \"Version: %n\n\" \"%CLEARCASE_XPN%\""
That will list all the selected versions, and you can redirect the output in a file, one for each view.
Then the comparison is trivial.
Is there a clearcase command to show me say all the files and the respective committers/activities that have changed in the last X hours/days? Something similar to svn/git/hg log?
Not directly, because ClearCase is file-centric, not repository centric.
So you can make your query for a component or a Stream (list of components+baselines).
For instance, to list all activities for a given stream, you can type (using the fmt option of lsact):
cleartool lsact -fmt "%n %d" -in aStream#\aPVob -user auser
But then, you need to filter on the date to get only the activities you want, and you can the describe each activities in order to get their changeset.
For the files, you can use a find query similar to "Find files in Clearcase view newer than a specific date?":
cleartool find <vobtag> -element "{created_since(target-data-time)}" -print
cleartool find <vobtag> -element "{created_since(target-data-time)}" -exec "cleartool desc -fmt \"%n %u %[activity]p\" \"%CLEARCASE_XPN%\""
Using -fmt options, you can display the user for that version, and the activity whose change set contains the specified version.
Command to find labels applied on particular branch..
Suppose i have a branch name called BR_test , i want to know what are all the labels applied on this branch.
If this was UCM, a simple lsbl would be enough:
cleartool lsbl -stream myStream#\mypvob
But if this is base ClearCase, the simple way would be to determine what element (directory or file) is always labeled (typically a root directory), and fetch all the labels on that element for a given branch, through a combination of cleartool find and cleartool describe, based on fmt_ccase format (Windows syntax here):
C:\mySnapshotView\myVob\myRootDir>
ct find . -nrec -name "." -ver "brtype(myBranch)" -exec "cleartool descr -fmt "%l" \"%CLEARCASE_XPN%\""
That will list all labels for all versions of that element for a specific branch.