Getting previous activity ids of a file in clearcase commandline - clearcase

I'm using windows. I need to extract activity ids of check ins in ClearCase.
I can get the current one through cleartool describe and then parsing the response for the word 'Activity'.
I'm looking to get the activity ids of it's previous versions.
How can I do that?

You don't have to parse the output of cleartool describe, if you combine it with fmt_ccase.
That allows you to:
get the previous version of an existing version
cd /path/to/view
cleartool describe -fmt "%[version_predecessor]p" afile
get all activity id with that version involved:
cd /path/to/view
cleartool describe -fmt "%[activity]p" afile##/a/previous/version
(that is using the version-extended pathname ##/... returned by the first cleartool describe)

Related

How to obtain previous baseline from stream

I can retrieve latest baseline which is always recommended in my case using following command
"cleartool desc -fmt \"%[rec_bls]CXp\" stream:".$SourceStream."\#\\".$pvob
I want to retrieve second latest baseline.Is it possible to obtain previous baseline from a given stream using cleartool command? previous applied baseline on any given component will also works.I need this to get difference between two streams from different projects which can be done by following command.
"cleartool diffbl -elements baseline:".$LastComponentBaseline." stream:".$CurrentStream;
You can start by looking at the output of cleartool lsbl: it does list (for a given stream and/or component).
Combined with fmt_ccase, you can grep the recommended baseline you know, and the line before, since lsbl lists baselines from the oldest to the newest
cleartool lsbl -fmt "%[component]Xp %n" -stream aStream#\aVob | grep -B 1 -E "yourComponent.*yourBaseline"
You need to grep for the right component name (displayed by the %[component]Xp format), as lsbl (on a stream) would list all baselines of all components.

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.

ClearCase UCM: Branch created of file that is not part of an activity. What happened?

I have somehow created a branch of a file in clearcase UCM that is not part of an activity. I have no idea how to reproduce this, but my stream is showing many files with this symptom. How can I find these files, remove them, and prevent it from happening again in the future?
Here is an example of one such file, names redacted to protect the innocent:
xxxxxxxxxxx.cpp##/main/xxx-integration/xxxxxx-xxxxxxxx/0 Rule: .../xxx-xxxxxxx/LATEST
A ct lsact -long | grep <filename> returns no results.
Update:
I used a find command to track down all the files that are on the branch given (and redacted) above, though I still do not understand the issue.
Per VonC's answer, where is what I ended up doing:
cleartool find . -type f -version "version(.../xxx/LATEST)&&version(.../xxx/0)" -print | tee ~/tmp/files2
I then read through the list of files generated to make sure they made sense, then I verified they were not attached to an activity and removed the versions:
cat ~/tmp/files2 | while read
do
if [ -z "$(ct describe -fmt "%[activity]p" $REPLY)" ]
then
ct rmbranch -f ${REPLY%/0}
fi
done
That can happen ig those file were checkout in a base ClearCase view, ie a non-UCM view, withg a simple config spec:
element * .../xxx-integration/LATEST -mkbranch xxxxxx-xxxxxxxx
You can use a find command similar to "How can I find all elements on a branch with version LATEST that has no label applied?".
The difference is: for each version found, you need to describe it in order to check if there is an activity attached to it or not (with a fmt_ccase):
cleartool describe -fmt "%[activity]p" "$CLEARCASE_XPN"

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.

Resources