How do I roll back a file checked in to Clearcase?
Asked Answered
R

4

19

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.)

Rostand answered 27/1, 2010 at 13:16 Comment(0)
R
25

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.

Rebec answered 27/1, 2010 at 17:55 Comment(7)
When you say "destroys information irretrievably", you are only talking about information related to the latest check-in (which was anyway incorrect), right? In that case, why do you say it is rarely a good thing? The check-in was a mistake after all, so what is the harm in removing the existence of those versions? Please share your knowledge.Vestry
@ArvindhMani I am talking about any version that you would rmver. And that would leave hyperlinks dangling (or remove them as well), which can compromise the integrity of other objects (like a full UCM baseline). If the latest version has no hyperlink and isn't referenced by another object, then yes, rmver is a solution.Rebec
@ArvindhMani The issue is that, while it may be working in your case, all you will remember is that "rmver works"... which will lead to a day where rmver will be carelessly used, and will do more damage. That is why I prefer to limit its usage.Rebec
there is no copy command in my system. What do you mean by copy?Poler
@Jerry Try cp instead. copy is for Windows.Rebec
@Vonc Can this be done from a version tree? Merging a particular version to the checked out version using the version tree GUI?Conservatoire
@Conservatoire Yes, provided your version tree is launched from the destination view (where the version is checked out)Rebec
S
3

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.

Spitsbergen answered 28/1, 2010 at 0:40 Comment(2)
@Kathy: you are not seeing a downside, but that is a very very bad solution. The only one you shall never ever do. Even though is may work in this case, you are better off preventing your users to ever do a rmver. Ever. Because it works here means one day they will use it again in a situation where it will breaks all kind of thing. Seriously: do not do that.Rebec
FWIW, in my personal situation, I do not have permissions to delete files in this way.Rostand
L
1

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.

Lightfingered answered 27/1, 2010 at 13:23 Comment(2)
Is this the best that CC can do? Oy. (I'm new to CC, have used svn exclusively for past 5 yrs.)Rostand
I know it's an old one, but I agree with JXG (I too have been using SVN for the last 6 years and CVS for years before that)... is the best CC can do? Suppose you have to back out a change and some 30-odd files in many dirs are affected. Why would it not have a "revert changes from this checkin" type of command?Lovesick
E
0

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.

Emphasis answered 28/7, 2022 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.