diff --git a/hgext/transplant.py b/hgext/transplant.py index fc4e0fecf40327ade4828bc96f6fa77720dab556_aGdleHQvdHJhbnNwbGFudC5weQ==..1f020021adfa017194f62282fa910cddbf69a2ca_aGdleHQvdHJhbnNwbGFudC5weQ== 100644 --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -20,6 +20,9 @@ from mercurial import patch, revlog, scmutil, util, error, cmdutil from mercurial import revset, templatekw +class TransplantError(error.Abort): + pass + cmdtable = {} command = cmdutil.command(cmdtable) @@ -171,11 +174,17 @@ del revmap[rev] if patchfile or domerge: try: - n = self.applyone(repo, node, - source.changelog.read(node), - patchfile, merge=domerge, - log=opts.get('log'), - filter=opts.get('filter')) + try: + n = self.applyone(repo, node, + source.changelog.read(node), + patchfile, merge=domerge, + log=opts.get('log'), + filter=opts.get('filter')) + except TransplantError: + # Do not rollback, it is up to the user to + # fix the merge or cancel everything + tr.close() + raise if n and domerge: self.ui.status(_('%s merged at %s\n') % (revstr, short(n))) @@ -259,8 +268,8 @@ p2 = node self.log(user, date, message, p1, p2, merge=merge) self.ui.write(str(inst) + '\n') - raise util.Abort(_('fix up the merge and run ' - 'hg transplant --continue')) + raise TransplantError(_('fix up the merge and run ' + 'hg transplant --continue')) else: files = None if merge: diff --git a/tests/test-transplant.t b/tests/test-transplant.t index fc4e0fecf40327ade4828bc96f6fa77720dab556_dGVzdHMvdGVzdC10cmFuc3BsYW50LnQ=..1f020021adfa017194f62282fa910cddbf69a2ca_dGVzdHMvdGVzdC10cmFuc3BsYW50LnQ= 100644 --- a/tests/test-transplant.t +++ b/tests/test-transplant.t @@ -212,4 +212,5 @@ > baz > EOF $ echo toremove > toremove + $ echo baz > baz $ hg ci -Amfoo @@ -215,4 +216,5 @@ $ hg ci -Amfoo + adding baz adding foo adding toremove $ cat <<EOF > foo @@ -226,8 +228,13 @@ adding added removing toremove $ echo bar > bar + $ cat > baz <<EOF + > before baz + > baz + > after baz + > EOF $ hg ci -Ambar adding bar $ echo bar2 >> bar $ hg ci -mbar2 $ hg up 0 @@ -229,10 +236,10 @@ $ hg ci -Ambar adding bar $ echo bar2 >> bar $ hg ci -mbar2 $ hg up 0 - 2 files updated, 0 files merged, 2 files removed, 0 files unresolved + 3 files updated, 0 files merged, 2 files removed, 0 files unresolved $ echo foobar > foo $ hg ci -mfoobar created new head $ hg transplant 1:3 @@ -235,8 +242,8 @@ $ echo foobar > foo $ hg ci -mfoobar created new head $ hg transplant 1:3 - applying a1e30dd1b8e7 + applying 46ae92138f3c patching file foo Hunk #1 FAILED at 0 1 out of 1 hunks FAILED -- saving rejects to file foo.rej @@ -250,7 +257,7 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ rm added $ hg transplant 1 - applying a1e30dd1b8e7 + applying 46ae92138f3c patching file foo Hunk #1 FAILED at 0 1 out of 1 hunks FAILED -- saving rejects to file foo.rej @@ -258,5 +265,5 @@ abort: fix up the merge and run hg transplant --continue [255] $ hg transplant --continue - a1e30dd1b8e7 transplanted as f1563cf27039 + 46ae92138f3c transplanted as 9159dada197d $ hg transplant 1:3 @@ -262,9 +269,9 @@ $ hg transplant 1:3 - skipping already applied revision 1:a1e30dd1b8e7 - applying 1739ac5f6139 - 1739ac5f6139 transplanted to d649c221319f - applying 0282d5fbbe02 - 0282d5fbbe02 transplanted to 77418277ccb3 + skipping already applied revision 1:46ae92138f3c + applying 9d6d6b5a8275 + 9d6d6b5a8275 transplanted to 2d17a10c922f + applying 1dab759070cf + 1dab759070cf transplanted to e06a69927eb0 $ hg locate added bar @@ -268,4 +275,5 @@ $ hg locate added bar + baz foo @@ -271,4 +279,27 @@ foo + +test multiple revisions and --continue + + $ hg up -qC 0 + $ echo bazbaz > baz + $ hg ci -Am anotherbaz baz + created new head + $ hg transplant 1:3 + applying 46ae92138f3c + 46ae92138f3c transplanted to 1024233ea0ba + applying 9d6d6b5a8275 + patching file baz + Hunk #1 FAILED at 0 + 1 out of 1 hunks FAILED -- saving rejects to file baz.rej + patch failed to apply + abort: fix up the merge and run hg transplant --continue + [255] + $ echo fixed > baz + $ hg transplant --continue + 9d6d6b5a8275 transplanted as d80c49962290 + applying 1dab759070cf + 1dab759070cf transplanted to aa0ffe6bd5ae + $ cd .. Issue1111: Test transplant --merge