Patchwork [3,of,9,standalone-strip] mq: extract checklocalchanges from `mq.queue`

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 25, 2013, 9:26 p.m.
Message ID <6ebf8c08f31e3c0148cf.1380144406@vulgaris>
Download mbox | patch
Permalink /patch/2632/
State Accepted
Commit 4495c6a272e0f6283eeb51906703fff8232c0bf4
Headers show

Comments

Pierre-Yves David - Sept. 25, 2013, 9:26 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1380105794 -7200
#      Wed Sep 25 12:43:14 2013 +0200
# Node ID 6ebf8c08f31e3c0148cfd961609e219419e78df9
# Parent  c29d0955623f6438844740dcdb9982c9055f4926
mq: extract checklocalchanges from `mq.queue`

The core part of `checklocalchanges` is now mq independent. We can extract it in
a standalone function to help the extraction of `strip` as discussed in issue3824.

A `checklocalchanges` function stay in `mq.queue` with the part related to
"refresh first" messages.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -962,20 +962,11 @@  class queue(object):
         if refresh:
             excsuffix = ', refresh first'
             # plain versions for i18n tool to detect them
             _("local changes found, refresh first")
             _("local changed subrepos found, refresh first")
-        cmdutil.checkunfinished(repo)
-        m, a, r, d = repo.status()[:4]
-        if not force:
-            if (m or a or r or d):
-                _("local changes found") # i18n tool detection
-                raise util.Abort(_("local changes found" + excsuffix))
-            if checksubstate(repo):
-                _("local changed subrepos found") # i18n tool detection
-                raise util.Abort(_("local changed subrepos found" + excsuffix))
-        return m, a, r, d
+        return checklocalchanges(repo, force, excsuffix)
 
     _reserved = ('series', 'status', 'guards', '.', '..')
     def checkreservedname(self, name):
         if name in self._reserved:
             raise util.Abort(_('"%s" cannot be used as the name of a patch')
@@ -2929,10 +2920,22 @@  def checksubstate(repo, baserev=None):
                 _("uncommitted changes in subrepository %s") % s)
         elif s not in bctx.substate or bctx.sub(s).dirty():
             inclsubs.append(s)
     return inclsubs
 
+def checklocalchanges(repo, force=False, excsuffix=''):
+    cmdutil.checkunfinished(repo)
+    m, a, r, d = repo.status()[:4]
+    if not force:
+        if (m or a or r or d):
+            _("local changes found") # i18n tool detection
+            raise util.Abort(_("local changes found" + excsuffix))
+        if checksubstate(repo):
+            _("local changed subrepos found") # i18n tool detection
+            raise util.Abort(_("local changed subrepos found" + excsuffix))
+    return m, a, r, d
+
 
 @command("strip",
          [
           ('r', 'rev', [], _('strip specified revision (optional, '
                                'can specify revisions without this '