changeset 27102:f97bb61b51e6 stable

localrepo.commit: check all files for resolve state (issue4972) Previously we were only checking modified files for their resolve state. But a file might be unresolved yet not in the modified state. Handle all such cases properly.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 30 Nov 2015 16:31:28 -0800
parents 6979fe2a6d75
children 2d437a0f3355
files mercurial/localrepo.py tests/test-commit-unresolved.t
diffstat 2 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Nov 15 22:18:48 2015 +0100
+++ b/mercurial/localrepo.py	Mon Nov 30 16:31:28 2015 -0800
@@ -1556,19 +1556,12 @@
             if merge and cctx.deleted():
                 raise error.Abort(_("cannot commit merge with missing files"))
 
-            unresolved, driverresolved = False, False
             ms = mergemod.mergestate(self)
-            for f in status.modified:
-                if f in ms:
-                    if ms[f] == 'u':
-                        unresolved = True
-                    elif ms[f] == 'd':
-                        driverresolved = True
 
-            if unresolved:
+            if list(ms.unresolved()):
                 raise error.Abort(_('unresolved merge conflicts '
                                     '(see "hg help resolve")'))
-            if driverresolved or ms.mdstate() != 's':
+            if ms.mdstate() != 's' or list(ms.driverresolved()):
                 raise error.Abort(_('driver-resolved merge conflicts'),
                                   hint=_('run "hg resolve --all" to resolve'))
 
--- a/tests/test-commit-unresolved.t	Sun Nov 15 22:18:48 2015 +0100
+++ b/tests/test-commit-unresolved.t	Mon Nov 30 16:31:28 2015 -0800
@@ -43,4 +43,25 @@
   (no more unresolved files)
   $ hg commit -m "Merged"
 
+Test that if a file is removed but not marked resolved, the commit still fails
+(issue4972)
+
+  $ hg up ".^"
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg merge 2
+  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 update -C .' to abandon
+  [1]
+  $ hg rm --force A
+  $ hg commit -m merged
+  abort: unresolved merge conflicts (see "hg help resolve")
+  [255]
+
+  $ hg resolve -ma
+  (no more unresolved files)
+  $ hg commit -m merged
+  created new head
+
   $ cd ..