diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -148,6 +148,8 @@ break if not abortstate: raise error.Abort(_('no operation in progress')) + if abortstate._opname == 'merge': + return hg.merge(repo, abort=True) if abortstate._abortfunc: return abortstate._abortfunc(ui, repo) raise error.Abort((_("%s does not support 'hg abort'") % diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -952,8 +952,8 @@ return ret -def merge(repo, node, force=None, remind=True, mergeforce=False, labels=None, - abort=False): +def merge(repo, node=None, force=None, remind=True, mergeforce=False, + labels=None, abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" if not abort: diff --git a/tests/test-abort.t b/tests/test-abort.t --- a/tests/test-abort.t +++ b/tests/test-abort.t @@ -628,9 +628,8 @@ Unshelve abort fails with appropriate message if there's no unshelve in progress $ hg abort - abort: merge does not support 'hg abort' - (use 'hg commit' or 'hg merge --abort') - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Abort due to pending changes @@ -902,3 +901,59 @@ $ hg abort abort: no operation in progress [255] + $ cd .. + +####TEST `hg abort` operation merge + + $ addcommit () { + > echo $1 > $1 + > hg add $1 + > hg commit -d "${2} 0" -m $1 + > } + + $ commit () { + > hg commit -d "${2} 0" -m $1 + > } + + $ hg init a + $ cd a + $ addcommit "A" 0 + $ addcommit "B" 1 + $ echo "C" >> A + $ commit "C" 2 + + $ hg update -C 0 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo "D" >> A + $ commit "D" 3 + created new head + +State before the merge + + $ hg status + $ hg id + e45016d2b3d3 tip + $ hg summary + parent: 3:e45016d2b3d3 tip + D + branch: default + commit: (clean) + update: 2 new changesets, 2 branch heads (merge) + phases: 4 draft + +Testing the abort functionality first in case of conflicts + + $ hg abort + abort: no operation in progress + [255] + $ hg merge + merging A + warning: conflicts while merging A! (edit, then use 'hg resolve --mark') + 1 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + + $ hg abort + aborting the merge, updating back to e45016d2b3d3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved +