Find Objects that have not a label in any version - clearcase

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.

Related

How to find where a string was added at first in code, with ClearCase?

I want to find in which ClearCase label a specific string was added in code?
I am using base ClearCase.
I recommended before (8 years ago) to limit the scope of your search and use the exec clause of a cleartool find.
Example:
cleartool find -all -type f -user myLogin \
-version "lbtype(A_LABEL)" \
-exec ...
If you can do so in a dynamic view, you can then directly grep the content of CLEARCASE_XPN, the variable set by cleartool find for each version found.
It reference an extended pathname that (in a dynamic view) you can directly read and grep for your code)
You can do so for each label you can find in your Vob, from the oldest to the newest.
Z:myvob>ct lstype -kind lbtype -short
Z:myvob>ct find . -version "lbtype(A_LABEL)" -print
If you are looking for a specific change in a given source file, the cleartool annotate command will give you a good start. If you're familiar with GIT, this is the equivalent of "git blame."
Annotate works only if the element is one of the text file types (text_file, utf?_text_file, etc.) since those store delta information on a per version basis.
One caveat is that this will tell you what version the change came from, but if that version was created by a merge, you may have to backtrack the merge to find the original location of the change. ALMToolbox's "visual annotate" tool does that for you, if I recall correctly.

How to find the username who created latest version of element in clearcase?

I am often getting a request like this. " Find the list of files changed from particular day".
I got answer to this as example given below
"cleartool find <Vobtag> -version "{brtype(IntegrationStream) && created_since(13-Jan.8:30)}" -print"
But few people are asking "Find the list of files changed and by whom". So that they can pin down the developer name and assign him the task to resolve issues.
Is it possible to pipeline the above command and find the user who made that version also?
You should be able to add to your find query a created_by member.
See the query language man page.
created_by (login-name)
In all cases, TRUE if the object was created by the user login-name (as shown by the describe command).
So your query would look like:
cleartool find <Vobtag> -version "{brtype(IntegrationStream) && created_since(13-Jan.8:30) && created_by(aUser)}" -print
The OP comments:
The command you have given will find the list of files created by particular person.
But I would like to find all the files created_since and also by whom it was created
True, for that you need to add a format parameter to your query, following the fmt_ccase man page.
Since cleartool find has no -fmt parameter, what you do is to pipe the result of the find query to a cleartool describe command (which can use a -fmt directive).
cleartool find <Vobtag> -version "{brtype(IntegrationStream) && created_since(13-Jan.8:30)}" -exec "cleartool describe -fmt \"%Xn : %u\n\" \"%CLEARCASE_XPN%\"
The second part of the command is:
-exec "cleartool describe -fmt \"%Xn : %u\n\" \"%CLEARCASE_XPN%\"
The important parameters are:
%u
User/group information associated with the object's creation event (modifiers: F, G, L); see also %[owner]p and %[group]p.
\"%CLEARCASE_XPN%\"
It represents the extended pathname of a version found by the find query.

How to find list of files created and modified in a UCM stream?

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.

Find changes between labels

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.

How to search files by label

As title, I'd like to list all the files with a given label under a directory. Which clearcase command can help me to do that ?
cleartool find is a good start.
You can execute those anywhere within your (snapshot or dynamic) view
To generate the list of those elements which contain a version with a predetermined label (REL1) attached, use the following syntax of the cleartool find command:
UNIX and Linux:
% cleartool find -all -element '{lbtype_sub(REL1)}' -print
Windows:
cleartool find -all -element "{lbtype_sub(REL1)}" -print
There is also a graphical way to find objects with a certain label called Report Builder (also known in ClearCase Explorer as Report Wizard). In Report Builder you can navigate to Elements/Labels which has the "Elements with Labels" and "Versions with Labels" reports. After the report runs you have the option to save the results as HTML, XML, or CSV.

Resources