Find elements on branch and with specific label - clearcase

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

Related

Clearcase Findmerge

I want to find all the files that have been changed on a label (eg label1) from my view. label1 Can be be applicable to multiple branches as well.
I tried following command, it did not work:
cleartool findmerge . -fve "{lbtype(label 1)}" -print
What would be the correct command?
If you want to find all the files that are labelled 'label1', a cleartool find would be more adequate than cleartool findmerge.
cleartool find . –version 'lbtype(label1)' -print
For listing the files (and not their versions) on all branches:
cleartool find -all -element '{lbtype_sub(label1)}'
See also:
"Additional examples of the cleartool find command"
"cleartool find examples"

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 elements of a label with version before LATEST

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

Cleartool - find unloaded/removed files

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.

Command to find labels applied on particular branch

Command to find labels applied on particular branch..
Suppose i have a branch name called BR_test , i want to know what are all the labels applied on this branch.
If this was UCM, a simple lsbl would be enough:
cleartool lsbl -stream myStream#\mypvob
But if this is base ClearCase, the simple way would be to determine what element (directory or file) is always labeled (typically a root directory), and fetch all the labels on that element for a given branch, through a combination of cleartool find and cleartool describe, based on fmt_ccase format (Windows syntax here):
C:\mySnapshotView\myVob\myRootDir>
ct find . -nrec -name "." -ver "brtype(myBranch)" -exec "cleartool descr -fmt "%l" \"%CLEARCASE_XPN%\""
That will list all labels for all versions of that element for a specific branch.

Resources