Patchwork [2,of,3] cmdutil: refactor checkunresolved

login
register
mail settings
Submitter timeless
Date Nov. 2, 2016, 7:01 p.m.
Message ID <8dae4ad6767cf3456dd2.1478113312@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/17288/
State Accepted
Headers show

Comments

timeless - Nov. 2, 2016, 7:01 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1478112353 0
#      Wed Nov 02 18:45:53 2016 +0000
# Node ID 8dae4ad6767cf3456dd2fc4b2a7b478d855091f7
# Parent  78cf30254354eafb993ed7f226eb70d7b7abb6dc
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r 8dae4ad6767c
cmdutil: refactor checkunresolved

localrepo.commit had code to check for unresolved merge conflicts,
it would be helpful for at least rebase to be able to use that
code without calling commit().

Patch

diff -r 78cf30254354 -r 8dae4ad6767c mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Nov 02 18:56:07 2016 +0000
+++ b/mercurial/cmdutil.py	Wed Nov 02 18:45:53 2016 +0000
@@ -3403,6 +3403,14 @@ 
 
     return cmd
 
+def checkunresolved(ms):
+    if list(ms.unresolved()):
+        raise error.Abort(_("unresolved merge conflicts "
+                            "(see 'hg help resolve')"))
+    if ms.mdstate() != 's' or list(ms.driverresolved()):
+        raise error.Abort(_('driver-resolved merge conflicts'),
+                          hint=_('run "hg resolve --all" to resolve'))
+
 # a list of (ui, repo, otherpeer, opts, missing) functions called by
 # commands.outgoing.  "missing" is "missing" of the result of
 # "findcommonoutgoing()"
diff -r 78cf30254354 -r 8dae4ad6767c mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Nov 02 18:56:07 2016 +0000
+++ b/mercurial/localrepo.py	Wed Nov 02 18:45:53 2016 +0000
@@ -1633,13 +1633,7 @@ 
                 raise error.Abort(_("cannot commit merge with missing files"))
 
             ms = mergemod.mergestate.read(self)
-
-            if list(ms.unresolved()):
-                raise error.Abort(_("unresolved merge conflicts "
-                                    "(see 'hg help resolve')"))
-            if ms.mdstate() != 's' or list(ms.driverresolved()):
-                raise error.Abort(_('driver-resolved merge conflicts'),
-                                  hint=_('run "hg resolve --all" to resolve'))
+            cmdutil.checkunresolved(ms)
 
             if editor:
                 cctx._text = editor(self, cctx, subs)