changeset 19822:a194a33f8cb2

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 26 Sep 2013 23:10:11 +0200
parents baab785e3ecf
children 6fb14d21fe9d
files hgext/mq.py hgext/strip.py tests/test-extension.t
diffstat 3 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Thu Sep 26 14:47:19 2013 +0200
+++ b/hgext/mq.py	Thu Sep 26 23:10:11 2013 +0200
@@ -77,6 +77,17 @@
 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgext/strip.py	Thu Sep 26 23:10:11 2013 +0200
@@ -0,0 +1,5 @@
+from mercurial import cmdutil
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+testedwith = 'internal'
--- a/tests/test-extension.t	Thu Sep 26 14:47:19 2013 +0200
+++ b/tests/test-extension.t	Thu Sep 26 23:10:11 2013 +0200
@@ -406,13 +406,16 @@
   > 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: