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
Related
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?
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"
Having a regular size-efficient backup for only the modified checkedout elements in all views would be a great thing for us, since a great deal of the defined dynamic/snapshot views cannot be included in the daily backup policy.
The following ksh code is near to what we would need for a dynamic view, but it trivially assumes that the first line in the config-spec file for the view always selects the checked-out element first ( *element * CHECKEDOUT* ). It will not work well in general.
For each versioned file in the view we would like to be able to add it to the backup list only if it is different from the last corresponding versioned element in the VOB that is selected for that view. (Only if it has been developed in the view).
[The solution would have to be valid for snapshot views also]
for CHECKEDOUT_FILE_IN_THE_VIEW in $( /usr/atria/bin/cleartool lsco -cview -avobs -short )
do
VERSIONED_FILE_NAME=$( /usr/atria/bin/cleartool describe -short ${CHECKEDOUT_FILE_IN_THE_VIEW} \
| sed -e's/CHECKEDOUT/LATEST/' )
if [ -f ${VERSIONED_FILE_NAME} ]; then
if [ -f ${CHECKEDOUT_FILE_IN_THE_VIEW} ]; then
diff -b ${CHECKEDOUT_FILE_IN_THE_VIEW} ${VERSIONED_FILE_NAME} > /dev/null
if [ $? -ne 0 ]; then
##-- The checked-out file in the view is different from the corresponding
##-- versioned element in the VOB. So it has to be added to the backup list.
echo "${VERSIONED_FILE_NAME}" >> ${F_LOG}
fi
fi
fi
done
Any idea(s) ?. TIA.
Javier C.
Frankly, for dynamic views, a simpler backup strategy would be to just zip and backup the view storage associated with said dynamic view (after a 'cleartool endivew -server aDynViewTag):
all the checked-out and private files are stored in the view storage (only for dynamic view)
but it won't take into account checked-out file with (yet) no modifications compared to their versioned counterpart.
If you need a generic solution both for dynamic and snaphot views, then you can refer to:
'How to find all checkedout files with ClearCase cleartool?' (a 'cleartool lsco' you are using), but you don't need to compute the LATEST version to make a system-based diff.
You can simply:
cleartool diff -pred ${CHECKEDOUT_FILE_IN_THE_VIEW}
If any modification exists between the checked-out version and its previous version, it will return something (for versions in snapshot or dynamic views).
See cleartool diff.
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 '~'.
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.