I have a file in my Clearcase repository. I checked it out and modified it, and then checked it back in.
I haven't done anything like make a baseline, or rebase, or deliver in my stream/view.
I regret having made the changes to this file--I should have undone the checkout, in retrospect.
How do I roll back the modifications? (Or undo, or revert, or whatever the correct nomenclature is.)
What is described by skwllsp can be be done in a dynamic view through the use of extended pathnames
cd m:/myDynamicView/MyVob/path/to/file
cleartool lsvtree myFile
cleartool checkout -c "cancel co" myFile
copy myFile##/main/xx myFile
cleartool checkin -nc myFile
with xx being the version number you want to restore.
But should you have made multiple checkins, including some you want to cancel, ClearCase allows you to cancel part of the previous checkins through Subtractive Merge
See IBM "to remove contributions of some versions" (and merge man page)
You can remove all changes from a range of versions at once. For example, the following command removes revisions to versions 14 through 16 on the main branch:
On the UNIX system or Linux:
cleartool merge -graphical -to opt.c -delete -version /main/14 /main/16
On the Windows system:
cleartool merge -graphical -to opt.c -delete -version \main\14 \main\16
You can also remove the changes from one version at a time. For example, the following commands remove only the changes in version 14 from the version of opt.c checked out the current view:
On the UNIX system or Linux:
cleartool merge -graphical -to opt.c -delete -version /main/14
On Windows systems:
cleartool merge -graphical -to opt.c -delete -version \main\14
Alternatively, in any of the examples above, you can leave out the -version argument if you use the version extended path for the contributor-version-selector.
Finally, the one thing to not do is a rmver.
This command destroys information irretrievably and this is rarely a good thing.
Clearcase can do much better than just making a new version where you undo the change!
Open the version history on your file, find the version you mistakenly checked in, and destroy it (select version to destroy and find the appropriate command under the Versions menu).
This is what rmver does too, if you want to use the command line.
As VonC said your this destroys your mistake irretrievably. I'm not seeing a downside to that.
Open version history for this file, then open in your editor a proper version of the file from the version tree, check out file once more, replace its with content of the previous correct version and check in. Don't forget to compare the previous version and the last version.
cleartool unco #filename should do the job for you.
But if the version in the main branch/ branch from where your branch is created, goes forward with versions, when you undo your checkout, the new version is acquired instead of the version from which you branched.
Related
I have a file called prog.c in clearcase, for example the user has checked out this file, say the user has checked out the version 3 of the file.
After that, if some other users checked in the same version of file. say the latest version be 6.
How to check the latest version of the file using the CLEARTOOL command?
One way would be a cleartool lsvtree yourFile:
That would display a textual representation of the version tree, allowing you to see if the version you have is the LATEST on a given branch.
But one nice trick I sometime use in snapshot view is: 'cleartool co -nc yourFile'.
if it works, I cleartool unco immediately.
but, if the version isn't the LATEST, the checkout will fail, with a warning asking to update first.
Note that in a dynamic view, the problem is slightly different: one can checkout (unreserved) while other checkout/check-in.
You will know you don't have the LATEST version on the checkin stage: it will complain you must merge with the actual latest version in order to create a "new latest" version which will the the result of the combination (merge) of your work and the later versions.
One way to know where your at, with a checked out version, is to do a:
cleartool descr -pred -fmt "%Sn" MyFile
(see "Change set predecessor using cleartool", and "How to list all my check-ins using ClearCase?")
"%Sn" will give you the branch and version of the file currently checked out.
You can compare that with:
cleartool descr -fmt "%Sn" M:\aDynamicView\Vob\path\to\myFile
If you have a dynamic view with the same config spec and no checkouts, you can use it as "reference view", and see if the branch version in that reference view is the same than the version previous to the one checked out in your local (snap or dyn) view.
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.
I need to retrieve a list of all the files that have been checked-in across baselines along with the owner name. I tried using the cleartool lsact command :
However, this command fetches just for one task and is a bit cumbersome to use. Is there a command which will retrieve all the tasks if I specify two baselines?
Thanks
A command like:
cleartool diffbl -act bl1#\apvob bl2#\apvob
will give you the list of activities which have new versions between baselines bl1 and bl2.
However, to get the list of files (ie elements, as in files or directories, and not versions as in all the updated versions even for a same file), the best way is to:
ensure those baselines are "full" baseline: promote them to full if needed:
cleartool chbl -full bl1#\apvob
cleartool chbl -full bl2#\apvob
(if they were already full, this command won't do anything)
list all elements which have the bl1 and bl2 labels on different versions:
cleartool find -all -element '{lbtype_sub(REL1) && lbtype_sub(REL2)}' ^
-version '{(lbtype(REL1) && ! lbtype(REL2)) || ^
(lbtype(REL2) && !lbtype(REL1))}' -print
See "Find changes between labels".
Note that this last question also mentions the "report builder packaged with ClearCase, which is interesting if you are after a solution involving a GUI and not a CLI (command line):
Again, if those baselines are full, you can use it to list (under Elements/Labels) either "Elements Changed Between Two Labels" or "Versions Changed Between Two Labels" depending on which you need.
Because ClearCase updates directory version numbers when files inside are created, our config-spec generating script is failing (details omitted).
So, as an example, given a file such as "/proj/src/scripts/build.sh##/main/branch42/3", how can we determine the latest version of the scripts directory that contains that version of the build.sh file.
Note: we're looking for a unix command-line solution that can be scripted.
If you do a ls /proj/src/scripts##/main/branch42/*/build.sh/main/branch42/3 you should get a list of all versions of the scripts directory that contain version .../3 of build.sh. Then you should be able to pick out the latest of those.
The above is probably not a fool proof approach, so you might try something more like
cleartool find /proj/src/scripts --allversions --nonvisible -name build.sh -version 'brtype(branch42) && version(3)' -print
(I no longer have a clearcase environment to test in, so the above is from memory and is not an accurate command)
Another approach is to:
set a label on the right version of the build.sh script and its directory (you can move that label when needed)
have a second dynamic view always configured to select that label
element * SCRIPT_LABEL
element /proj/... .../branch42/LATEST
That way, you simply read the information you need from that second 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.