D6588: abort: added support for merge
taapas1128 (Taapas Agrawal)
phabricator at mercurial-scm.org
Sat Jun 29 19:39:09 UTC 2019
taapas1128 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This adds support of `hg merge --abort` to `hg abort`.
Results are shown as tests.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6588
AFFECTED FILES
mercurial/commands.py
mercurial/hg.py
tests/test-abort.t
CHANGE DETAILS
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
+
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/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'") %
To: taapas1128, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list