# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1520766638 -32400
#      Sun Mar 11 20:10:38 2018 +0900
# Branch stable
# Node ID eeb87b24aea7f547f6d95b812dd080dc6e9ab194
# Parent  9639c433be54191b4136b48fe70fc8344d2b5db2
amend: abort if unresolved merge conflicts found (issue5805)

It was checked by repo.commit() before e8a7c1a0565a "cmdutil: remove the
redundant commit during amend."

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -34,6 +34,7 @@ from . import (
     graphmod,
     match as matchmod,
     mdiff,
+    mergeutil,
     obsolete,
     patch,
     pathutil,
@@ -3212,6 +3213,11 @@ def amend(ui, repo, old, extra, pats, op
             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)
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -415,6 +415,23 @@ Refuse to amend during a merge:
   [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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to