strip: move the strip helper function for mq to strip
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 26 Sep 2013 23:43:00 +0200
changeset 19825 4b4997068143
parent 19824 237e40b2c1ff
child 19826 4b1cbcfdabf7
strip: move the strip helper function for mq to strip The next patch finally move the command. No joke! (hey, this is for issue3824)
hgext/mq.py
hgext/strip.py
--- a/hgext/mq.py	Thu Sep 26 23:32:52 2013 +0200
+++ b/hgext/mq.py	Thu Sep 26 23:43:00 2013 +0200
@@ -63,7 +63,7 @@
 from mercurial.node import bin, hex, short, nullid, nullrev
 from mercurial.lock import release
 from mercurial import commands, cmdutil, hg, scmutil, util, revset
-from mercurial import repair, extensions, error, phases, bookmarks
+from mercurial import extensions, error, phases, bookmarks
 from mercurial import patch as patchmod
 from mercurial import localrepo
 from mercurial import subrepo
@@ -88,6 +88,7 @@
             pass
     stripext = extensions.load(dummyui(), 'strip', '')
 
+strip = stripext.strip
 checksubstate = stripext.checksubstate
 checklocalchanges = stripext.checklocalchanges
 
@@ -2911,25 +2912,6 @@
         q.savedirty()
     return 0
 
-def strip(ui, repo, revs, update=True, backup="all", force=None):
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-
-        if update:
-            checklocalchanges(repo, force=force)
-            urev, p2 = repo.changelog.parents(revs[0])
-            if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
-                urev = p2
-            hg.clean(repo, urev)
-            repo.dirstate.write()
-
-        repair.strip(ui, repo, revs, backup)
-    finally:
-        release(lock, wlock)
-
-
 @command("strip",
          [
           ('r', 'rev', [], _('strip specified revision (optional, '
--- a/hgext/strip.py	Thu Sep 26 23:32:52 2013 +0200
+++ b/hgext/strip.py	Thu Sep 26 23:43:00 2013 +0200
@@ -1,5 +1,8 @@
 from mercurial.i18n import _
-from mercurial import cmdutil, util
+from mercurial import cmdutil, hg, util
+from mercurial.node import nullid
+from mercurial.lock import release
+from mercurial import repair
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -34,3 +37,21 @@
             raise util.Abort(_("local changed subrepos found" + excsuffix))
     return m, a, r, d
 
+def strip(ui, repo, revs, update=True, backup="all", force=None):
+    wlock = lock = None
+    try:
+        wlock = repo.wlock()
+        lock = repo.lock()
+
+        if update:
+            checklocalchanges(repo, force=force)
+            urev, p2 = repo.changelog.parents(revs[0])
+            if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
+                urev = p2
+            hg.clean(repo, urev)
+            repo.dirstate.write()
+
+        repair.strip(ui, repo, revs, backup)
+    finally:
+        release(lock, wlock)
+