[PATCH 1 of 2 standalone-strip] mq: extract strip as a standalone extension (issue3824)

Martin Geisler martin at geisler.net
Thu Sep 26 16:48:40 CDT 2013


pierre-yves.david at ens-lyon.org writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1380144102 -7200
> #      Wed Sep 25 23:21:42 2013 +0200
> # Node ID f2d6590c1873f5d9fbd903a2ea467a19de4d4c13
> # Parent  72982741c525e1d0b06096bc7eafc780a4f2274f
> mq: extract strip as a standalone extension (issue3824)

This is a great idea! Thanks for making my life easier when I explain
new users how to remove changesets.

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

The commit message above is wrapped inconsistently -- maybe by hand?

> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -55,17 +55,20 @@ discarded. Setting::
>    keepchanges = True
>  
>  make them behave as if --keep-changes were passed, and non-conflicting
>  local changes will be tolerated and preserved. If incompatible options
>  such as -f/--force or --exact are passed, this setting is ignored.
> +
> +This extension used to provide a strip commands. This command now lives

Should be "a strip command", without the "s".

[...]

> +# 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) prefers this explicite code.
> +    class dummyui(object):
> +        def debug(self, msg):
> +            pass
> +    stripext = extensions.load(dummyui(), 'strip', '')
> +
> +strip = stripext.strip
> +checksubstate = stripext.checksubstate
> +checklocalchanges = stripext.checklocalchanges

I guess you don't simply do 'from hgext import strip as stripext' since
you want to avoid loading the extension twice in case the user already
enabled 'strip'?

If it isn't a big problem to load it twice, then I would just import it.
Those who already use mq will probably not enable strip too, so they
will only import the module once. New users will hopefully only enable
the strip extension, so they also only get it once.

> diff --git a/hgext/strip.py b/hgext/strip.py
> new file mode 100644
> --- /dev/null
> +++ b/hgext/strip.py
> @@ -0,0 +1,217 @@
> +"""This extension contains the strip commands.

Command should be singular here again.

-- 
Martin Geisler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130926/e5a2f2c4/attachment.pgp>


More information about the Mercurial-devel mailing list