bigoops
bigoops

Reputation: 31

Committed and pushed incorrect revision in TortoiseHg

I accidentally committed and pushed the incorrect revisions and was wondering if there was a way to undo the changes?

I used the rollback feature in TortoiseHg, but I don't believe that works when a commit has been pushed.

The push target is the publishing server. Both side do not have evolve extension.

I was planning on using back out or revert all files, but I have no idea which one is more appropriate to use.

Upvotes: 3

Views: 46

Answers (1)

StayOnTarget
StayOnTarget

Reputation: 12988

Let's assume you had a series of revisions like this:

*-C-B-A

where C and B are the incorrect ones.

Since everything is pushed you can't erase C and B themselves. But you can undo their effects.


One approach is the following:

  1. Update locally to C and make sure the working files are all clean (unmodified)
  2. In THG right click on A in the revision list and select "revert to revision"
  3. Click OK to any prompts, etc.
  4. Now the working directory files will be identical to the state at A. This effectively undoes changes in C and B
  5. Commit, creating revision D
  6. Test, verify, etc.
  7. Push

The final result would be

*-D-C-B-A

where D is the undo.


That approach mashes together the undo of both C and B. You might want to make that a bit more clear, so another approach would be:

  1. Update locally to C
  2. In THG right click on C in the revision list and select "backout". This will create a new commit which is the reverse of C
  3. Do this again for B
  4. Test, verify, etc.
  5. Push

In this second approach you now have two separate commits, in the reverse order of C and B, that undo each of them in turn.

The final result would be

*-B'-C'-C-B-A

Upvotes: 1

Related Questions