This command gets elements of a label with latest version:
cleartool find . -element "{lbtype_sub(LABEL1) && version(/main/LATEST)}" -print
how do I get elements of a label with version before LATEST?
If you mean, how to get any version with the right label, but which aren't LATEST, you could do it in two passes:
cleartool find . -version "{lbtype_sub(LABEL1)}" -print > labelled_versions.txt
That would find all versions with the right label.
Remember a label can be applied to only one version per element.
You can restrict it per branch if you want:
cleartool find . -version "{lbtype_sub(LABEL1) && brtype(myBranch)}" -print > labelled_versions.txt
# for instance, for main:
cleartool find . -version "{lbtype_sub(LABEL1) && brtype(main)}" -print > labelled_versions.txt
(That would exclude versions labelled, but part of a different branch than main)
Then you can use a dynamic view, and for each version found, check if that version is the same as the one selected in your dynamic view (using fmt_ccase):
cleartool descr -fmt "%n" M:\MyView\myVob\path\to\myFile
Related
Using cleartool, how do I find elements (file or folder):
on a specific branch
and
with a specific label?
I mentioned before how to search elements by label.
You should be able to add a brtype selector (as in here) to restrict to a given branch:
Unix:
cleartool find -all -element '{lbtype_sub(REL1) && brtype(BRANCHNAME)}' -print
Windows:
cleartool find -all -element "{lbtype_sub(REL1) && brtype(BRANCHNAME)}" -print
I want to find objects that have not got a LABEL in any version.
I can check if any object has a LABEL in its LATEST version with following command :
cleartool find . -version "version(/main/LATEST) && !lbtype(MYLABEL)" -print
And this command also lists all versions :
cleartool find . -version "!lbtype(MYLABEL)" -print
I want the object list that has not got label (MYLABEL) in any versions. How can I do this?
You can first try looking for elements instead (with the lbtype_sub query primitive):
cleartool find . -ele "!lbtype_sub(MYLABEL)" -print
See "Additional examples of the cleartool find command"
About *_sub query primitives
When using the ClearCase find command in what circumstances should the *_sub query primitives (attype_sub, label_sub and attr_sub) be used instead of just lbtype or attype?
When the type being queried does not apply to the "level" (-element -branch -version) being queried.
For example, query for a label using -element: labels are only on versions within elements
(you can limit to files only with -type f, or folders only with with -type -d)
If that does not work would recommend a three steps process.
find all the elements (file or folder) that have one version with that label
find all the elements
remove the first elements from the second list
The end result is what you are looking for.
Is there a command in Cleartool which i can use to list all files which have been removed from a branch?
Thanks
The basic command to find anything in ClearCase is... cleartool find, also illustrated in "ClearCase UCM: Need to See Content of Deleted File".
In your case, you would search for versions of files which aren't at the LATEST of a branch:
cleartool find . -type f -version "! version(.../BRANCH/LATEST)" -print
(see version selector for more on this '.../' notation)
To display only the file (and not all the versions):
cleartool find . -type f -element "! version(.../BRANCH/LATEST)" -print
The OP linuxlewis mentions in the comments:
this will show all differences which exist between sibling branches. I just want to be able see the file names,if any were removed,from the current branch
I mention the possibility of a grep for BRANCH, to detect files which have versions in BRANCH but not LATEST)
However, a cleaner solution is to add another filter to the search: && version(.../BRANCH)
cleartool find . -type f -element "! version(.../BRANCH/LATEST) && version(.../BRANCH)" -print
That will search all "elements" (files or directories in ClearCase) which have versions in branch BRANCH, but not one in BRANCH/LATEST.
Whenever developer tries to debug the code they wanted to know list of files created and modified from particular day . I use
cleartool find command with created_since , but it finds only the files which are created not modified.
How to find both?
The cleartool find command can give you what you want, provided you look for versions created since a date, not element (file or directory).
See "Additional examples of the cleartool find command":
cleartool find <vobtag> -version "{created_since(target-data-time)}" -print
Since you are in UCM, you can limit that search to a specific branch name (corresponding to a specific Stream)
cleartool find <vobtag> -version "{brtype(BRANCH) && created_since(target-data-time)}" -print
Add the user in this request:
cleartool find <vobtag> -version "{created_by(user2) && brtype(BRANCH) && created_since(target-data-time)}" -print
And you should get what you need for a developer for a given Stream and date.
Below is example of finding all files changed after 27-Aug-2014
cleartool find . -version "{created_since(27-Aug-2014)}" -print
I followed what brainimus had to say here.
IBM Clear Case-> Administration -> Report builder.
In the Tree view Under \Reports Select Elements, and then choose the appropriate option.
Using cleartool I am able to find all the files associated with a label using something like:
ct find -avobs -version "lbtype (Build-Label)" -print
How do I find all objects changed (including adds and deletes) between two labels?
In ClearCase (under Administration in my install) there is Report Builder. Under Elements/Labels you can select either "Elements Changed Between Two Labels" or "Versions Changed Between Two Labels" depending on which you need. You can then select the path to analyze and select the two labels to compare.
After the process runs you have the option to save the results as HTML, XML, or CSV.
There is a another way to do it , where LABEL1 is the old label and LABEL2 is the latest. Check the date of creation of the labels and swap them before issuing the command as it prints the negation of the && conditional statement. Works like magic!
$(cleartool find $PWD -ver "!lbtype($LABEL1) && lbtype($LABEL2)" -print)
As mentioned in the answer to "How to search files by label"
cleartool find -all -element "{lbtype_sub(REL1)}" -print
is simpler and lbtype_sub allow the query to be true if any version of the element has the label
(see query_language man page)
cleartool find -all -element '{lbtype_sub(REL1) && lbtype_sub(REL2)}' ^
-version '{!(lbtype(REL1) && lbtype(REL2)) && ^
(lbtype(REL2) || lbtype(REL1))}' -print
would find all elements that do not have both labels, listing all versions in the current VOB labeled either REL1 or REL2 but not both.
Note: if the label is a UCM baseline, this is off course even simpler (ct diffbl):
ct diffbl -ver BL1#\myPVob BL2#\myPVob
To find all elements, also those deleted or not selected by your config_spec, add –nvisible to the find options.
For comparision I have a shell script called freeze-list which more or less runs the same find command as you have there (redirecting the output to <label>.versions).
I then have some other perl scripts which takes two such files, reads them and compares each element. I have for instance freeze-compare-text for a plain diff -u output, freeze-compare-kdiff3 to start kdiff3 comparision on each file where there are some changes (with some intelligence to avoid false positives where the 0 element on a new branch is identical with the starting version etc). And I also have a freeze-compare-diffstat (basically piping the output to diffstat).
If you just are interested in finding changes between to labels as a one time operation, you can run
ct find -avobs –nvisible -version "lbtype(label1)" -print | sort > label1.versions
ct find -avobs –nvisible -version "lbtype(label2)" -print | sort > label2.versions
comm -3 label1.versions label2.versions
which will list all elements which do not have identical versions in label1 and label2.