amend: abort if unresolved merge conflicts found (issue5805) stable
authorYuya Nishihara <yuya@tcha.org>
Sun, 11 Mar 2018 20:10:38 +0900
branchstable
changeset 36844 eeb87b24aea7
parent 36759 9639c433be54
child 36845 ff2370a70fe8
amend: abort if unresolved merge conflicts found (issue5805) It was checked by repo.commit() before e8a7c1a0565a "cmdutil: remove the redundant commit during amend."
mercurial/cmdutil.py
tests/test-commit-amend.t
--- a/mercurial/cmdutil.py	Tue Mar 06 13:19:54 2018 -0600
+++ b/mercurial/cmdutil.py	Sun Mar 11 20:10:38 2018 +0900
@@ -34,6 +34,7 @@
     graphmod,
     match as matchmod,
     mdiff,
+    mergeutil,
     obsolete,
     patch,
     pathutil,
@@ -3212,6 +3213,11 @@
             if subs:
                 subrepo.writestate(repo, newsubstate)
 
+        # avoid cycle (TODO: should be removed in default branch)
+        from . import merge as mergemod
+        ms = mergemod.mergestate.read(repo)
+        mergeutil.checkunresolved(ms)
+
         filestoamend = set(f for f in wctx.files() if matcher(f))
 
         changes = (len(filestoamend) > 0)
--- a/tests/test-commit-amend.t	Tue Mar 06 13:19:54 2018 -0600
+++ b/tests/test-commit-amend.t	Sun Mar 11 20:10:38 2018 +0900
@@ -415,6 +415,23 @@
   [255]
   $ hg ci -m 'merge'
 
+Refuse to amend if there is a merge conflict (issue5805):
+
+  $ hg up -q foo
+  $ echo c > a
+  $ hg up default -t :fail
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ hg resolve -l
+  U a
+
+  $ hg ci --amend
+  abort: unresolved merge conflicts (see 'hg help resolve')
+  [255]
+
+  $ hg up -qC .
+
 Follow copies/renames:
 
   $ hg mv b c