oscarmlage oscarmlage

Darcs: Fixing a wrong amend

Written by oscarmlage on

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:

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