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.
--- 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 ..