# HG changeset patch # User Brendan Cully # Date 1164923518 28800 # Node ID 752884db503788686278621fb51f5cabce7eaab8 # Parent ccc7a9eb0e5ee18750e67dd68434f0a8c4f85bd2 transplant: recover added/removed files after failed application diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -196,12 +196,14 @@ class transplanter: 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: diff --git a/tests/test-transplant b/tests/test-transplant --- a/tests/test-transplant +++ b/tests/test-transplant @@ -67,13 +67,16 @@ foo bar baz EOF +echo toremove > toremove hg ci -Amfoo -d '0 0' cat < 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 ci -mfoobar -d '0 0' hg transplant 1:3 echo merge > foo hg transplant --continue +hg locate diff --git a/tests/test-transplant.out b/tests/test-transplant.out --- a/tests/test-transplant.out +++ b/tests/test-transplant.out @@ -77,16 +77,22 @@ applying 4333daefcb15 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