transplant: recover added/removed files after failed application
authorBrendan Cully <brendan@kublai.com>
Thu, 30 Nov 2006 13:51:58 -0800
changeset 3726 752884db5037
parent 3725 ccc7a9eb0e5e
child 3727 0fb66912040a
transplant: recover added/removed files after failed application
hgext/transplant.py
tests/test-transplant
tests/test-transplant.out
--- a/hgext/transplant.py	Thu Nov 30 11:32:40 2006 -0800
+++ b/hgext/transplant.py	Thu Nov 30 13:51:58 2006 -0800
@@ -196,12 +196,14 @@
         if patchfile:
             try:
                 files = {}
-                fuzz = patch.patch(patchfile, self.ui, cwd=repo.root,
-                                   files=files)
-                if not files:
-                    self.ui.warn(_('%s: empty changeset') % revlog.hex(node))
-                    return
-                files = patch.updatedir(self.ui, repo, files, wlock=wlock)
+                try:
+                    fuzz = patch.patch(patchfile, self.ui, cwd=repo.root,
+                                       files=files)
+                    if not files:
+                        self.ui.warn(_('%s: empty changeset') % revlog.hex(node))
+                        return
+                finally:
+                    files = patch.updatedir(self.ui, repo, files, wlock=wlock)
                 if filter:
                     os.unlink(patchfile)
             except Exception, inst:
--- a/tests/test-transplant	Thu Nov 30 11:32:40 2006 -0800
+++ b/tests/test-transplant	Thu Nov 30 13:51:58 2006 -0800
@@ -67,13 +67,16 @@
 bar
 baz
 EOF
+echo toremove > toremove
 hg ci -Amfoo -d '0 0'
 cat <<EOF > foo
 foo2
 bar2
 baz2
 EOF
-hg ci -mfoo2 -d '0 0'
+rm toremove
+echo added > added
+hg ci -Amfoo2 -d '0 0'
 echo bar > bar
 hg ci -Ambar -d '0 0'
 echo bar2 >> bar
@@ -84,3 +87,4 @@
 hg transplant 1:3
 echo merge > foo
 hg transplant --continue
+hg locate
--- a/tests/test-transplant.out	Thu Nov 30 11:32:40 2006 -0800
+++ b/tests/test-transplant.out	Thu Nov 30 13:51:58 2006 -0800
@@ -77,16 +77,22 @@
 4333daefcb15 transplanted to 5f42c04e07cc
 % transplant --continue
 adding foo
+adding toremove
+adding added
+removing toremove
 adding bar
-1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-applying c029d661401c
+2 files updated, 0 files merged, 2 files removed, 0 files unresolved
+applying a1e30dd1b8e7
 foo
 Hunk #1 FAILED at 1.
 1 out of 1 hunk FAILED -- saving rejects to file foo.rej
 patch command failed: exited with status 1
 abort: Fix up the merge and run hg transplant --continue
-c029d661401c transplanted as 1b09cda4cf1b
-applying 67f0722fdc4f
-67f0722fdc4f transplanted to faa04033bb41
-applying 84c5126bd0d2
-84c5126bd0d2 transplanted to b35f4019ccc9
+a1e30dd1b8e7 transplanted as e6d0b5145568
+applying 1739ac5f6139
+1739ac5f6139 transplanted to 48f780141a79
+applying 0282d5fbbe02
+0282d5fbbe02 transplanted to 821d17b1a3ed
+added
+bar
+foo