changeset 19813:76796fe65bad

mq: extract checksubstate from the queue class This function does not need any of the the `mq.queue` method or attributes. It is indirectly used by the `strip` command. We are trying to extract this command in a standalone extension as discussed in issue issue3824.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 25 Sep 2013 11:24:43 +0200
parents 5d6cfdc38a3d
children 4495c6a272e0
files hgext/mq.py
diffstat 1 files changed, 21 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Sep 25 12:28:40 2013 +0200
+++ b/hgext/mq.py	Wed Sep 25 11:24:43 2013 +0200
@@ -945,23 +945,6 @@
             return top, patch
         return None, None
 
-    def checksubstate(self, repo, baserev=None):
-        '''return list of subrepos at a different revision than substate.
-        Abort if any subrepos have uncommitted changes.'''
-        inclsubs = []
-        wctx = repo[None]
-        if baserev:
-            bctx = repo[baserev]
-        else:
-            bctx = wctx.parents()[0]
-        for s in sorted(wctx.substate):
-            if wctx.sub(s).dirty(True):
-                raise util.Abort(
-                    _("uncommitted changes in subrepository %s") % s)
-            elif s not in bctx.substate or bctx.sub(s).dirty():
-                inclsubs.append(s)
-        return inclsubs
-
     def putsubstate2changes(self, substatestate, changes):
         for files in changes[:3]:
             if '.hgsubstate' in files:
@@ -987,7 +970,7 @@
             if (m or a or r or d):
                 _("local changes found") # i18n tool detection
                 raise util.Abort(_("local changes found" + excsuffix))
-            if self.checksubstate(repo):
+            if checksubstate(repo):
                 _("local changed subrepos found") # i18n tool detection
                 raise util.Abort(_("local changed subrepos found" + excsuffix))
         return m, a, r, d
@@ -1031,7 +1014,7 @@
         diffopts = self.diffopts({'git': opts.get('git')})
         if opts.get('checkname', True):
             self.checkpatchname(patchfn)
-        inclsubs = self.checksubstate(repo)
+        inclsubs = checksubstate(repo)
         if inclsubs:
             inclsubs.append('.hgsubstate')
             substatestate = repo.dirstate['.hgsubstate']
@@ -1505,7 +1488,7 @@
             cparents = repo.changelog.parents(top)
             patchparent = self.qparents(repo, top)
 
-            inclsubs = self.checksubstate(repo, hex(patchparent))
+            inclsubs = checksubstate(repo, hex(patchparent))
             if inclsubs:
                 inclsubs.append('.hgsubstate')
                 substatestate = repo.dirstate['.hgsubstate']
@@ -2931,6 +2914,24 @@
         q.savedirty()
     return 0
 
+def checksubstate(repo, baserev=None):
+    '''return list of subrepos at a different revision than substate.
+    Abort if any subrepos have uncommitted changes.'''
+    inclsubs = []
+    wctx = repo[None]
+    if baserev:
+        bctx = repo[baserev]
+    else:
+        bctx = wctx.parents()[0]
+    for s in sorted(wctx.substate):
+        if wctx.sub(s).dirty(True):
+            raise util.Abort(
+                _("uncommitted changes in subrepository %s") % s)
+        elif s not in bctx.substate or bctx.sub(s).dirty():
+            inclsubs.append(s)
+    return inclsubs
+
+
 @command("strip",
          [
           ('r', 'rev', [], _('strip specified revision (optional, '