mq: extract checklocalchanges from `mq.queue`
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 25 Sep 2013 12:43:14 +0200
changeset 19814 4495c6a272e0
parent 19813 76796fe65bad
child 19815 378567bf9f74
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.
hgext/mq.py
--- a/hgext/mq.py	Wed Sep 25 11:24:43 2013 +0200
+++ b/hgext/mq.py	Wed Sep 25 12:43:14 2013 +0200
@@ -964,16 +964,7 @@
             # 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):
@@ -2931,6 +2922,18 @@
             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",
          [