cmdutil: refactor checkunresolved
authortimeless <timeless@mozdev.org>
Wed, 02 Nov 2016 18:45:53 +0000
changeset 30272 3d38a0bc774f
parent 30271 0fa1a41d04e4
child 30273 86f4ef63d507
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().
mercurial/cmdutil.py
mercurial/localrepo.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()"
--- 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)