Patchwork [1,of,6,standalone-strip-long-version] mq: prepare a strip extension for extraction

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 26, 2013, 9:57 p.m.
Message ID <b3237c62404cfab9b9ad.1380232666@vulgaris>
Download mbox | patch
Permalink /patch/2648/
State Accepted
Commit a194a33f8cb230c3e2bd8c4a0105b992e9d48ce4
Headers show

Comments

Pierre-Yves David - Sept. 26, 2013, 9:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1380229811 -7200
#      Thu Sep 26 23:10:11 2013 +0200
# Node ID b3237c62404cfab9b9ad7733d2cf7f241294518e
# Parent  72982741c525e1d0b06096bc7eafc780a4f2274f
mq: prepare a strip extension for extraction

Strip will lives in its own extension. The extension is surprisingly called
`strip`. (as discussed in issue3824) The `mq` extension force the use of the
strip extension when its enabled. This will both necessary for backward
compatibility (people expect `mq` to comes with strip) and become some utility
function used by `mq` will move in the strip extension.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -75,10 +75,21 @@  seriesopts = [('s', 'summary', None, _('
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 testedwith = 'internal'
 
+# force load strip extension formely included in mq and import some utility
+try:
+    stripext = extensions.find('strip')
+except KeyError:
+    # note: load is lazy so we could avoid the try-except,
+    # but I (marmoute) prefer this explicite code.
+    class dummyui(object):
+        def debug(self, msg):
+            pass
+    stripext = extensions.load(dummyui(), 'strip', '')
+
 # Patch names looks like unix-file names.
 # They must be joinable with queue directory and result in the patch path.
 normname = util.normpath
 
 class statusentry(object):
diff --git a/hgext/strip.py b/hgext/strip.py
new file mode 100644
--- /dev/null
+++ b/hgext/strip.py
@@ -0,0 +1,5 @@ 
+from mercurial import cmdutil
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+testedwith = 'internal'
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -404,17 +404,20 @@  Issue811: Problem loading extensions twi
   > cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")}
   > commands.norepo += " debugextensions"
   > EOF
   $ echo "debugissue811 = $debugpath" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
+  $ echo "strip=" >> $HGRCPATH
   $ echo "hgext.mq=" >> $HGRCPATH
   $ echo "hgext/mq=" >> $HGRCPATH
 
 Show extensions:
+(note that mq force load strip, also checking it's not loaded twice)
 
   $ hg debugextensions
   debugissue811
+  strip
   mq
 
 Disabled extension commands:
 
   $ ORGHGRCPATH=$HGRCPATH