[PATCH V5] mercurial: add debugextensions command (issue4676)

Yuya Nishihara yuya at tcha.org
Thu Sep 24 10:22:58 CDT 2015


On Thu, 24 Sep 2015 15:21:58 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1441896787 -7200
> #      Thu Sep 10 16:53:07 2015 +0200
> # Node ID fd715ace75242d561e5fb6eefdbed61ddcc7f57b
> # Parent  ea489d94e1dc1fc3dc1dcbef1c86c18c49605ed1
> mercurial: add debugextensions command (issue4676)
> 
> Add debugextensions command to help users debug their extension
> problems. If there are no extensions command prints nothing,
> otherwise it prints names of extension modules. If quiet or
> verbose option is not specified it prints(after extensions name)
> last version of mercurial in which given module was tested for
> non internal modules or not tested with user mercurial version.
> 
> If verbose is specified it prints following information for every
> extension: extension name, import source, testedwith and buglink
> informations.
> 
> Extensions are printed sorted by extension name.
> 
> diff -r ea489d94e1dc -r fd715ace7524 mercurial/commands.py
> --- a/mercurial/commands.py	Sat Aug 22 17:08:37 2015 -0700
> +++ b/mercurial/commands.py	Thu Sep 10 16:53:07 2015 +0200
> @@ -19,7 +19,7 @@
>  import merge as mergemod
>  import minirst, revset, fileset
>  import dagparser, context, simplemerge, graphmod, copies
> -import random
> +import random, operator
>  import setdiscovery, treediscovery, dagutil, pvec, localrepo
>  import phases, obsolete, exchange, bundle2, repair, lock as lockmod
>  import ui as uimod
> @@ -2171,6 +2171,45 @@
>          localrevs = opts.get('local_head')
>          doit(localrevs, remoterevs)
>  
> + at command('debugextensions', formatteropts, [], norepo=True)
> +def debugextensions(ui, **opts):
> +    '''show information about active extensions'''
> +    exts = extensions.extensions(ui)
> +    fm = ui.formatter('debugextensions', opts)
> +    for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
> +        extsource = extmod.__file__
> +        exttestedwith = getattr(extmod, 'testedwith', None)
> +        if exttestedwith is not None:
> +            exttestedwith = exttestedwith.split()
> +        extbuglink = getattr(extmod, 'buglink', None)
> +
> +        fm.startitem()
> +
> +        if ui.quiet or ui.verbose:
> +            fm.write('name', '%s\n', extname)
> +        else:
> +            fm.write('name', '%s', extname)
> +            if not exttestedwith:
> +                fm.plain(_(' (untested!)\n'))
> +            else:
> +                if exttestedwith == ['internal'] or \
> +                                util.version() in exttestedwith:
> +                    fm.plain('\n')
> +                else:
> +                    lasttestedversion = exttestedwith[-1]
> +                    fm.plain(' (%s!)\n' % lasttestedversion)
> +
> +        fm.condwrite(ui.verbose and extsource, 'source',
> +                 _('  location: %s\n'), extsource or "")
> +
> +        fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
> +                 _('  tested with: %s\n'), ' '.join(exttestedwith or []))
> +
> +        fm.condwrite(ui.verbose and extbuglink, 'buglink',
> +                 _('  bug reporting: %s\n'), extbuglink or "")

Well, I personally prefer 'none' over '""' because these variables are
undefined in extension. But it is a kind of bikeshedding topic.

So overall, this patch looks good to me.

Regards,


More information about the Mercurial-devel mailing list