Find files selected by the config spec with specific properties in Clearcase - clearcase

I am using Clearcase dynamic view with a complex config spec. I need a command line command to find files where the version selected by the config spec has a specific property, such as:
has a specific label
does not have a specific label
is on a specific branch
etc.
I was looking at the documentation of the cleartool find command, but found no rule such as "version selected by the config spec".

A simple
cleartool describe -l /path/to/your/view/path/to/your/file
should be enough to display all the informations you need.
Combine that with the fmt_ccase formatting options page, and you can display directly only the label and the branch name:
cleartool describe -fmt "%Sn %l" /path/to/your/view/path/to/your/file
See:
%Sn
Short name:
For a version, a short form of the version ID: branch-pathname/version-number.
For other objects, the null string.
Now, if you want to find all files with a version of a specific property within your view, use the -cview option of find.
See "Additional examples of the cleartool find command":
To print all versions selected by your view that have a LABEL applied:
cleartool find . -cview -version "lbtype(LABEL)" -print
Following the same idea:
To print all versions selected by your view that are in a given branch:
cleartool find . -cview -version "brtype(BRNAME)" -print

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.

Find Objects that have not a label in any version

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.

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.

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