clearcase ucm baseline - clearcase

Is there any way to get the composte baseline information from the current view in command line .
I am using the comand in my script. It's displaying the list of the commands which include composite and ovverride component baselines in my view .
cleartool lsstream -fmt "%[found_bls]NXp\n" -view $VIEW_NAME
I need only the composite baseline as output for my command.
Is there any command to findout the composite baseline in current view ? pls help .

I guess your composite baselines are rootless components, so you can check the components and display only rootless. You can use cleartool describe for that.

A composite baseline can list its immediate dependencies, so as described in this script, you can attempt to list those for each baselines.
the one that does return an output (without error) is your composite baseline.
cleartool describe -fmt "%[depends_on]Np\n" {baseline selector}
However, building on my previous answer about "search the output line and save in variable", what you can do is describe each baseline, asking for its dependencies, and grepping for the line which contains an arobase '#':
Only composite baselines will return fully qualified baseline names, with arobase in it, as opposed to a non-composite baseline, which will return... nothing)
cleartool lsstream -fmt "%[found_bls]CXp" -view $VIEW_NAME | tr -s " " "\012" | xargs cleartool descr -fmt "%n %[depends_on]Cp" | grep "#" | sed -e "s/ .*//"
For more visibility:
cleartool lsstream -fmt "%[found_bls]CXp" -view $VIEW_NAME \
| tr -s " " "\012"
| xargs cleartool descr -fmt "%n %[depends_on]Cp"
| grep "#" | sed -e "s/ .*//"

Related

Clearcase: List all comments messages in stream

I have read this and run the below command :
cleartool lsact -r -in stream:aStream#\aPVob -fmt "%n %c"
After running this I got :
SOLNSxxxx Created automatically as a result of 'Work on' action in ClearQuest
I didn't get this as I am expecting the comment message against every activity and files checked-in in activity with commit message.
And will this change anything in clearquest too ?
Please let me know.
as I am expecting the comment message against every activity and files checked-in in activity with commit message.
No, that would return the name and comment of the activity only, not of its change set versions.
See "How to find files associated with a ClearCase UCM activity?": for each version return, you would need to apply a cleartool descr -fmt "%n %c"
Try (not tested)
cleartool describe -fmt "%[versions]CQp" activity-title#\aPVob |\
xargs cleartool descr -fmt "%n %c"
If the first describe list all versions on one line, use:
cleartool describe -fmt "%versionsCp\n" activity:<your activity>#<your pVOB> | perl -pe 's/\,\s?/\n/g'
# or
cleartool describe -fmt "%[versions]CQp\n" activity:<your activity>#<your pVOB> | perl -pe 's/\,\s?/\n/g'

Clear Case/CCRC : Command line usage

I am a new user to Clearcase/CCRC :
I want to learn using cleartool commands in windows platform for CCRC.
I have created a snapshot view using CCRC.
I want to search for a first occurence of a string in a file (in all the branches) using cleartool command.
For eg :
If a func name XXXX is introduced in File Y at version 10, then i want the command which will search for the function XXXX (in file Y) from base version till the version the function is introduced and should output me as version 10.
Please help me to do this.
Once your snapshot view is loaded, you don't need a cleartool command.
You can use a simple grep command in order to search within the files.
A cleartool find command would be useful to search for a string within the message comment of a version of a file, not for the file content itself. See those examples
UNIX/Linux:
cleartool find -all -ver "! lbtype(<non-existing label>)" -exec 'cleartool
desc -fmt "Version: %n\tComment: %c\n\n" $CLEARCASE_XPN' | grep <the string
you are looking for>
Windows:
cleartool find -all -ver "! lbtype(<non-existing label>)" -exec "cleartool
desc -fmt \"Version: %n\tComment: %c\n\n\" %CLEARCASE_XPN%" | findstr "<the
string you are looking for>"
For a given file, you can list all versions with fmt_ccase:
cleartool find -name "yourfile" -exec "cleartool desc -fmt \"%Ln\" \"%CLEARCASE_XPN%\" && cleartool diff -pred \"%CLEARCASE_XPN%\"|grep XXXX"
(note: on Windows, you can use grep with GoW: Gnu on Windows)
The idea is to list all versions for a given file, and for each:
print the version (cleartool desc -fmt "%Ln")
diff with the previous version and grep for XXXX

Which tag or branch is created from a particular branch

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.

Get list of elements having the specific "Requirement X" comment on elements

I would like to get the list of elements of "myvob/project/" having the comment "Requirement X" with cleartool command.
Is it possible ?
I don't think there is a "cleartool find" query ready for that.
You could combine a cleartool find with the exec part to describe each element with their full name and comment, and then grep on the relevant comment.
See additional find examples:
Find a particular string in a comment by searching all versions of all elements in a VOB.
Note: Example syntax includes formatting for the version and the comment:
UNIX/Linux:
cleartool find -all -ver "! lbtype(<non-existing label>)" \
-exec 'cleartool desc -fmt "Version: %n\tComment: %c\n\n" $CLEARCASE_XPN' \
| grep <the string you are looking for>
Windows:
cleartool find -all -ver "! lbtype(<non-existing label>)" \
-exec "cleartool desc -fmt \"Version: %n\tComment: %c\n\n\" %CLEARCASE_XPN%" \
| findstr "<the string you are looking for>"

ClearCase: Find files having exactly one specific label and not more

I'd like to find files in ClearCase that are labeled with a specific label but that do not have any other labels set.
For example, if I have files labeled like this:
file1 LBL_A, LBL_B
file2 LBL_A
I'd like to have a query that gives me just file2 and not file1.
Is there a way to do this with cleartool find? If this is not possible to do with a single query, I'd also be happy for any ideas how to do this in several steps (I'll be calling cleartool from a perl script, so it will be easy to save lists of files temporarily and run further commands on them).
Thanks a lot in advance!
Jan
Assuming LBL_A is the (only) label you want running
cleartool find /some/dir -version 'lbtype(LBL_A)' -print | xargs cleartool describe -fmt "%n: %l"
should give
file1: (LBL_A, LBL_B)
file2: (LBL_A)
as output which you then can check in your perl script or filter through sed -n 's/\(.*\): (LBL_A)/\1/p' (assuming no colons in filenames).
Update: As VonC correctly points out, the command above will fail for files with spaces in. To handle that run as:
cleartool find ... -print | tr '\012' '\000' | xargs -0 cleartool ....
which will translate newlines into ascii null and then have xargs use that as delimiter.
You can do this directly without having to pipe:
cleartool find . -ver "lbtype(LBL_A) && !lbtype(LBL_B)" -print
hlovdal's answer illustrates that, in this case, you have to find more elements than you need, and then filter them (despite all the ClearCase find features).
Note:
cleartool find . -type f -element 'lbtype_sub(LBL_A)' -print
could give you directly the elements (and not the version which may not be interesting in this case). You can find the version with -version and a format directive as explained below.
With the help of fmt_ccase, you can tailor the output to get precisely what your perl script will need to go on:
cleartool find . -type f -element 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%En %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","
-fmt "%En %l\n" will display the full path of the element (instead of the version: /a/b/myFile##/main/myVersion) => /a/b/myFile'. the '\n` ensure one result per line.
-version and -fmt "%n %l\n" would display the version
\"$CLEARCASE_XPN\": the double quotes arount the extended path of the version found ensure a file with spaces in its name will still work.
grep -v ",": if there is any comma, that means "more than one label"
%Cl: avoid displaying the all list of labels. Anyway, if there are more than one, you are not interested!
So, for finding the exact version:
cleartool find . -type f -version 'lbtype_sub(LBL_A)' -exec 'cleartool describe -fmt "%n %Cl\n" \"$CLEARCASE_XPN\"' | grep -v ","|awk '{sub(/ \(.*/,"");print}'
Note:
The above works with unix syntax. The windows syntax would be:
cleartool find . -type f -element "lbtype(LBL_A)" -exec "cleartool describe -fmt \"%n %Cl\n\" \"%CLEARCASE_XPN%\"" | grep -v "," | gawk "{gsub(/ \(.*,"");print}"
, which would list the version of files with only one (correct) label.
awk '{sub(/ \(.*/,"");print}' will transform "myFile##/main/myVersion (LBL_A)" into "myFile##/main/myVersion"

Resources