Clearcase: list element labels in a view - version-control

Using ClearCase, I would like to retrieve all the elements of the VOB that do not have a particular label.
I am trying to do something similar to the following but it doesn't work.
Any help ?
cleartool find . -elem '( ! (lbtype(MYLABEL)))' -print

It should be a query similar to:
cleartool find . -elem '! lbtype_sub(MYLABEL)' -print
From cleartool find and query_language:
lbtype_sub (label-type-name)
With elements: TRUE if the element has a version that is labeled label-type-name.
More details in "ClearCase: How to find elements that do NOT have a particular label"

Related

How can I stop find from searching a dir tree once it finds a match?

This is a variant of "How can I stop find from searching after first result found?" which I posted earlier today but is different enough to warrant a new question (IMO). It involves the find command ant potentially a perl soln if find can't do what I need.
Using find, I want to search a dir tree for all instances of dirs with name "out". Once an instance of "out" is found, I want it to stop searching under that dir but keep searching other paths for "out".
Consider this example...
mkdir -p top/a/b/out/c/d/out/e/leaf
mkdir -p top/a/bb/cc/out/dd/ee/out/ff/gg/out/hh/leaf
I want to find...
top/a/b/out
top/a/bb/cc/out
... but no other instances of "out".
Also, I want it to stop searching (wasting time) once it hits an instance of "out" in a path.
I am going to run this in perl, so I suppose I could get creative and write some recursive func to do this. And so I will also tag this with question with "perl" should that be the eventual solution.
Use the -prune action:
find top -name out -print -prune
This action prevents find from recursing into a directory.

Dynamically change find -maxdepth value given specific subdirectoy name

tl:dr I am trying to get find to completely ignore a specific subdirectory regardless of depth.
I am asking this question in reference to a line of code from maldets open source. It is the find command that generates the filelist that the scanner is to examine.
I know find will start at whatever dir specified, at a given maxdepth value.
Is it possible to change the maxdepth level at say dir/subdir/Thisleveldir so that when using the flag -D search nothing below Thisleveldir/ is listed?
For instance I want to search the /home directory to a max depth of 15
find /home -maxdepth 15 -type f -size +100M
until the pwd is /home/user/ReallyHugeDirThatDoesntNeedToBeSearched/ at which point -maxdepth gets set to 1
then once the pwd again is not that specific subdirectory -maxdepth reverts to its previous value of 15.
Is this possible?

Query labels with a specific attribute in ClearCase

How can I query those of the labels in ClearCase with cleartool that have a specific attribute.
I can list the labels with
lstype -kind lbtype
but I'd like to get only those that have an attribute called TestAttr.
You can
first find all the version with a certain attribute
then describe those versions in order to display their respective branch
(unix syntax)
cleartool find . -version 'attype(an_attribute_name)' \
-exec 'cleartool descr -fmt "%Sn" "$CLEARCASE_XPN" '
You will still need to parse the result to extract the branch, and sort -u the result.
The OP comments:
I'd like to query the labels not the files. I have no files with that attribute
Then find is the wrong command.
The best you could do is to list all labels in a given VOB, and describe them in order to display their attribute (if they have one)
ct lstype -kind lbtype -invob vob:/avob -fmt "%n ~ %[an_attribute_name]a"
Only the lines with some value displayed after the "~" (an arbitrary separator just put here to easily distinguish the name of the label from its attribute value) are to be considered.
A label with no attribute (at least not the 'an_attribute_name' attribute) will display only its name followed by "~", without any other data after the '~'.

how find objects between two labels in clearcase

I would like to get all sources/objects between two releases that happened within a month from clearcase. I wrote the below command and it displays only less number of sources compared to the actual one.
Please advive where I am wrong
cleartool find <path> -element "lbtype (Label b) && ! lbtype(label a) && ! -element (.../Branch1/latest)" -print
where:
label a is the label of last month release
label b is the current label
and branch1 is the branch from where all release happened
Thanks in advance
To see in general what has changed between two dates:
cleartool find . -version 'created_since(10-Jan) && !created_since(11-Jan)' -print
But in your case, you missing probably a '_sub' directive (see find examples for more requests):
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.
cleartool find <path> -element "lbtype_sub(Label b) && ! lbtype_sub(label a) && ! -element (.../Branch1/latest)" -print

ClearCase: How to find elements that do NOT have a particular label

I'm looking for a ClearCase command that will list all the elements that are visible in my current view, but do NOT have a particular label applied to them.
Say for example, most of the elements that are visible in my view have LABEL_X applied to them. I want a list of those elements that do not have LABEL_X.
I obviously need to use cleartool find, but the usage and ClearCase man page baffle me in terms of how to construct a query like this.
This should work:
ct find -all -ele '! lbtype_sub(LABEL_X)' -print
ct find -ele '! lbtype_sub(LABEL_X)' -print
Notes:
ct stands for cleartool
Unix syntax here (for windows, replace simple quotes with double quotes)
beware of the space between ! and lbtype_sub (in winodws you do not need the space)
-ele very IMPORTANT to get only one occurrence of a given file (and not all the different versions of a file matching a criteria)
-ele limits the search to elements, not versions (that would trigger a lot more results with versions involved...)
-all list all elements included "deleted" (that is "unreferenced") ones.
The second line lists only visible elements (in the current view)
You should execute those second command lines on the sub-directory of your choice within a given ClearCase (snapshot or dynamic view): all files within that sub-directory (and sub-sub directories...) matching the cirteria will be listed.
Warnings:
files and directories are listed. If you want only files, add -type f to the query:
ct find -type f -ele '!lbtype_sub(LABEL_X)' -print
what is displayed is the extended path for elements, that is the name of the file followed with ##.
To list only the name without ##, use '-nxn' (no extendedpathname option)
ct find -nxn -ele '!lbtype_sub(LABEL_X)' -print
Another more complex but also more complete way to list only the name without ##, is to use descr -fmt. For instance:
ct find . -ele "!lbtype_sub(LABEL_X)" -exec "cleartool descr -fmt \"%En %d\n\" \"%CLEARCASE_PN%\""
ct find . -ele '! lbtype_sub(LABEL_X)' -exec 'cleartool descr -fmt "%En %d\n" "$CLEARCASE_PN"'
would give you (in windows or unix syntax) the date and name of the files and directories not labeled LABEL_X.
With that 'descr -fmt' display, you can combine any kind of information and presentation you want for the result.
Above works, but remember to specifiy -cview to get JUST the current view, otherwise you'll get files from all the other views as well.
I needed to use the following on my Linux clearcase install:
cleartool find -cview -all -version '\!lbtype(LABEL_X)' -print
The syntax from VonC's post did not work properly with the "!" not being escaped.