diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py index 0b73f1353b..0e8a841d10 100644 --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -247,16 +247,20 @@ def _matcheol(file, back): util.writefile(file, newdata) -@internaltool("abort", nomerge) -def _iabort(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): - if fcd.changectx().isinmemory(): +@internaltool("abort", fullmerge) +def _iabort(repo, mynode, orig, fcd, *args, **kwargs): + if not fcd.changectx().isinmemory(): + # Support coming soon; it's tricker to do without IMM and has to be + # implemented per-command. + raise error.Abort(_("--tool :abort only works with in-memory merge")) + + res = _imerge(repo, mynode, orig, fcd, *args, **kwargs) + if res: raise error.AbortMergeToolError( _("hit merge conflicts, and --tool :abort passed") ) else: - # Support coming soon; it's tricker to do without IMM and has to be - # implemented per-command. - raise error.Abort(_("--tool :abort only works with in-memory merge")) + return res @internaltool("prompt", nomerge) diff --git a/tests/test-rebase-inmemory-abort-tool.t b/tests/test-rebase-inmemory-abort-tool.t index 7793e9dc03..c4703fc37c 100644 --- a/tests/test-rebase-inmemory-abort-tool.t +++ b/tests/test-rebase-inmemory-abort-tool.t @@ -1,6 +1,5 @@ Tests the :abort merge tool - $ newrepo $ enable rebase fbamend morestatus $ setconfig morestatus.show=True $ setconfig rebase.singletransaction=True @@ -8,6 +7,7 @@ Tests the :abort merge tool $ setconfig rebase.experimental.inmemory.nomergedriver=False $ setconfig rebase.experimental.inmemory.newconflictswitching=True $ setconfig rebase.experimental.inmemorywarning="rebasing in-memory!" + $ newrepo $ hg debugdrawdag <<'EOS' > c @@ -23,22 +23,26 @@ Tests the :abort merge tool $ hg up c 2 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo "local change" > b + + +Confirm it fails when rebasing a change that conflicts: $ hg rebase -r tip -d . --tool :abort rebasing in-memory! rebasing 3:955ac081fc7c "g" (tip) + merging c hit merge conflicts, and --tool :abort passed; exiting. $ hg st M b $ cat b local change -A rebase without a conflict behaves the same: +Confirm rebase without a merge behaves the same: $ hg rebase -r tip -d .~1 --tool :abort rebasing in-memory! rebasing 3:955ac081fc7c "g" (tip) saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/955ac081fc7c-77e57574-rebase.hg -It fails without IMM: +Confirm the flag fails without IMM: $ setconfig rebase.experimental.inmemory=False $ hg up -C . @@ -46,7 +50,35 @@ It fails without IMM: $ hg st $ hg rebase -r tip -d . --tool :abort rebasing 3:20b9638feb86 "g" (tip) + merging c transaction abort! rollback completed abort: --tool :abort only works with in-memory merge [255] + +Confirm that it rebases a three-way merge, but no conflict: + $ newrepo + $ $TESTDIR/seq.py 1 5 > a + $ hg commit -Aq -m "base" + $ $TESTDIR/seq.py 1 10 > a + $ hg commit -q -m "extend to 10" + $ hg up -q .~1 + $ $TESTDIR/seq.py 0 5 > a + $ hg commit -q -m "prepend with 0" + $ hg log -G -r 0:: -T '{rev} {desc}' + @ 2 prepend with 0 + | + | o 1 extend to 10 + |/ + o 0 base + + $ hg up -qC 0 + $ hg rebase -r 1 -d 2 --tool :abort + rebasing in-memory! + rebasing 1:12cba56c6d27 "extend to 10" + merging a + saved backup bundle to $TESTTMP/repo2/.hg/strip-backup/12cba56c6d27-14ff6d99-rebase.hg + $ hg cat -r tip a | wc -l | xargs + 11 + +^ (xargs is used for trimming)