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

JXG
  • 7,263
  • 7
  • 32
  • 63

4 Answers4

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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. – Arvindh Mani Dec 09 '14 at 07:41
  • 2
    @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. – VonC Dec 09 '14 at 07:45
  • 2
    @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. – VonC Dec 09 '14 at 07:46
  • there is no `copy` command in my system. What do you mean by `copy`? – xxks-kkk Dec 07 '16 at 07:12
  • 1
    @Jerry Try `cp` instead. `copy` is for Windows. – VonC Dec 07 '16 at 07:15
  • @Vonc Can this be done from a version tree? Merging a particular version to the checked out version using the version tree GUI? – Jozef Jul 17 '18 at 17:35
  • 1
    @Jozef Yes, provided your version tree is launched from the destination view (where the version is checked out) – VonC Jul 18 '18 at 12:35
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.

  • 4
    @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. – VonC Jan 28 '10 at 05:12
  • FWIW, in my personal situation, I do not have permissions to delete files in this way. – JXG Jan 28 '10 at 07:55
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.

  • 1
    Is this the best that CC can do? Oy. (I'm new to CC, have used svn exclusively for past 5 yrs.) – JXG Jan 27 '10 at 13:27
  • 2
    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? – Jon Aug 23 '12 at 15:49
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.

Alex
  • 1
  • 1