Darcs: Fixing a wrong amend

I must admit I often get confused when recording a new patch based on a previous one. Sometimes I amend instead of creating a new record, and once it's done it's not easy to rollback. Well, really it is if you have a backup of the original patch. And this is how I treated to handle it...

First of all, having blundered with the amend, make a repository backup on disk. Once it's done the process should be:

  • Amend other changes to that wrong patch, no matter really, we're going to unpull the patch in next step.
  • Unpull the patch with the wrong amend.
  • Pull the original patch (remember, we should have a copy of the original patch -before the wrong amend- to restore it).
  • Synchronize the repo backup copy to the current one excluding _darcs metadata directory.
$ cp -r myrepo myrepo.back
$ cd myrepo
$ darcs amend file1 file2
  * patch X
$ darcs unpull
  * patch X
Shall I unpull this patch? (1/1): y
$ dars apply patch-X-original.dpatch
$ cd ..
$ rsync -lprtvvzog --exclude '_darcs' myrepo.back/ myrepo/

Now your repo should be exactly as before to make the wrong amend. Once again, the power of the backups is priceless.

code

About the author

Óscar
has doubledaddy super powers, father of Hugo and Nico, husband of Marta, *nix user, Djangonaut and open source passionate.