I'm trying to find a list of fiels pointing to Version 0 in a view. I have tried several options with the find command and could get the output that i wanted. Can someone help/direct me here? Any help is much appreciated. Thanks.
You can do that for a given branch, as I mention in "Command to delete branches of Clearcase element with “0” versions":
cleartool find -avobs -branch'{
brtype(mybranch)&&!
(version(.../mybranch/1))}'
-print
You can replace mybranch by the name of a stream for which you want to clean any version /0.
Related
Suppose I have a file with versions 0 to 4. On version 2 I applied a label called mylabel. Now I want to do a find query using cleartool which gives me all versions created after my labelled version 2. That is I only want to get versions 3 and 4 as output, but not versions 0-2.
I know how to find all versions except the labelled one:
cleartool find . -version "!lbtpye(mylabel)" -print
There is also a command to get the history of this element:
cleartool lshistory -minor PATH_TO_FILE
This theoretically gives me the date when the label was applied, so I could do
cleartool find . -version "created_since(date)" -print
But the lshistory command always outputs the full history of the element and I feel it is too much to parse all this information just to get the desired date.
So basically I want to know if there is a more elegant way to do this. I could imagine that I could maybe first check which version has mylabel (because the version number is already provided by the find query) and then search for files with a version higher than the labelled version. So in my example with mylabel at version 2 I would hope for something like:
cleartool find . -version "version( > /main/2)" -print
After VonC's answer I should mention that the labeltype will only be created once and the label itself moved every few days. It is therefore not possible to check for the time the labeltype was created.
version( > /main/2) jas no equivalence in the ClearCase config spec 'version selectors'.
That means an easier option should rely on a convention, like the convention the date of applying the label should be very close to the date of creating the label type.
Meaning the mklbtype shoudl be done just before mklabel, and you could then use the label type creation date for your cleartool find . -version "created_since(date)" -print query.
Basically, the crux of the issue is to keep track of the date where the label where last applied (or moved, since it is here a shifting label).
Another approach would be to store that date as an attribute attached to the lbtype: only one lbtype, and one attribute changed each time the label is moved.
See cleartool mkattr.
I have a file test.cpp somebody added a few lines of code i don't know when but i'm assuming it was in a specific range of time that i know.I want to find the activity that was used to deliever this changes, i found a lot of versions of this element in the version tree of this element, but all the activities that i was able to see were as a result of a rebase, i need to find the source activity that was in charge of adding this few lines of code.
Is there any way to do that ?
For each deliver activity (that you can see in the version tree), you can list the contributing activities with
cleartool lsact -contrib activity:anact#/apvob # on unix #/vobs/apvob
See "Finding which developer activities were delivered in a specific delivery"
Then you need to describe each activity found, to see if your file is in it.
cleartool descr -l activity:anact#/avob
Obviously, you also can use a cleartool annotate, in order to see the versions in that file: see "How to use ClearCase Annotate".
If you see one line which interest you, check its version n# 'x' and use cleartool descr -l file#/main/.../x to find its corresponding activity.
I'm trying to recursively delete some versions/files from a specific branch.
find delivers the right files. Now it would be up to rmver to remove the version but this gives me an error. I'm struggling with the syntax.
cleartool> find Component\Test -element "brtype(P_Testing_device)" -exec "rmver -f \"%CLEARCASE_PN%##\main\G_Testing_device\P_Testing_device\LATEST\""
cleartool: Error: Extra arguments: "%CLEARCASE_PN%##\main\G_Testing_device\P_Testing_device\LATEST\"
What's wrong with that?
How would you recursively delete versions from a Branch?
First don't if you can avoid it. rmver, as I explain in "How do I undo a checkin in ClearCase remote client", is very dangerous.
If you have hyperlinks attached to the versions you are removing (definitively from ClearCase), like merge links (deliver or rebase links of your are using UCM), you risk ending up with many "dangling hyperlinks", which is not good.
Second, I would try first:
find Component\Test -element "brtype(P_Testing_device)" -exec 'rmver -f "%CLEARCASE_PN%##\main\G_Testing_device\P_Testing_device\LATEST"'
To rule yout any issue with weak vs. strong quoting (as in "CLEARCASE_XPN not parsed as variable in clearcase command")
If that doesn't work, I would recommend finding all the right versions and putting them into a file, then piping the content of that file to a cleartool rmver.
A much safer route is to cleartool lock -obs the branch, making it non-modifiable and invisible for the future version trees.
So I'm writing a script at work where I have to go through all the projects in a ClearCase vob, look for a file and parse some info from said file.
Naturally, I wouldn't want to load every single project so I'm using cleartool to retrieve the unloaded files.
First, I'm using the find command to locate the files. This was my first attempt:
root>cleartool find C:/viewpath -name file.txt -version "lbtype(Version-label)" -print -nr
Viewpath is the path to the project where I'm currently looking for the file. The file I'm looking for is file.txt on the version specified by Version-label.
This gave me no result whatsoever, even though I knew file.txt existed on that version.
I figured out it was looking through an old version of the directory, the latest on the main-branch, which was before file.txt was added to the directory. I tried this instead:
root>cleartool find C:/viewpath##/Version-label -name file.txt -version "lbtype(Version-label)" -print -nr
And got this result, which was what I was looking for
C:/viewpath\file.txt##\main\branch\41
So now that I knew where I could find the file I tried to get it.
root>cleartool get -to savepath C:/viewpath\file.txt##\main\branch\41
Which gave me this result
cleartool: Error: "C:/viewpath\file.txt##\main\branch\41" does not exist, or is not a ClearCase version, or is a checked out version which was removed.
Also tried
root>cleartool get -to savepath C:/viewpath\file.txt##/Version-label
With the same result
I can get files added to the directory when it was still on the main-branch, so it is still searching through the directory on the main-branch, where file.txt is nowhere to be found.
How do I tell it to look through a version of the directory from after it was branched from main?
I would really recommend for you to try those same commands in a dynamic view.
As illustrated here, a dynamic view gives you access to extended path (the file##/branch/version syntax), which means command like get will work.
You have in this question an example of search (cleartool find) using extended paths.
As explained in "In ClearCase, how can I view old version of a file in a static view, from the command line?", you can browse (as in 'change directory to') the various extended paths of a file in a dynamic view.
I want to check out a directory , let's say /vobs/myvob/src/ to add a new file in this directory. But by mistake rather than checked out /vobs/myvob/src I checked out /vobs/myvob/scr/ and even worse checked in it. Then directory scr has a new version : scr#mybranch/1 (let's say I'm working on branch mybranch)
After realized that I've made a mistake, I remove the newly created version by:
ct rmver scr#myranch/1
then use ct ls parent_dir_of_scr to do the double check and I found although scr#mybranch/1 disappeared, scr#mybranch/0 is still there .
Not 100% sure but I'm afraid I should not try to remove that version in the same way , cus it might let clearcase remove a version in main as well.
So my question is how should I do a totally "clean up" in this situation .
Need your help . thanks in advance .
First, as mentioned in How do I roll back a file checked in to Clearcase?, the one command to never ever do is rmver.
Even if in your case it could be appropriate, this is simply too dangerous, for it removes the version and all its associated metadata (hyperlinks, labels and so on).
Then, you mention:
rather than checked out /vobs/myvob/src I checked out /vobs/myvob/scr/...
... well /vobs/myvob/src is quite similar to /vobs/myvob/src here. I do not see any differences between the "two" directories.
If you want to add a file to a directory through the CLI cleartool, you will need to:
checkout /vobs/myvob/src (parent directory)
mkelem the file to add
checkin the parent directory
Finally, the "version 0" you see is only a "declarative" version to act as a starting point for branches.
That is why the other answers suggest you to rmbranch (remove the branch) for that element. It only serves the purpose of cleaning the lsvtree (version tree).
"cleartool rmbranch -force $element"
as mentioned in the ten best scripts.
Even if you remove version 1 of a file on your branch, your branch will remain (with version 0). If you really want to do a clean-up you can remove the branch (ct rmbranch your_branch) for the file -- it won't remove the version from mainline.
If you want to completely remove a version of an object (file or directory) from Clearcase control, I suggest you to use the following command:
cleartool rmver –xbranch –xlabel –xattr –xhlink test.txt##\main\3
Command options are described on this snip2code post.