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

Yuya Nishihara yuya at tcha.org
Wed Sep 23 13:12:29 UTC 2015


On Wed, 23 Sep 2015 10:55:38 +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 bc4c10eca4f569f526cafb8f07aa046d2b104bc4
> # 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 bc4c10eca4f5 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 informations about active extensions'''

My spell checker complains about "informations" :-)

> +    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)
> +
> +        fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
> +                 _('  tested with: %s\n'), ' '.join(exttestedwith))

If exttestedwith is None, it crashes.
Can you add a test for that case?

> +
> +        fm.condwrite(ui.verbose and extbuglink, 'buglink',
> +                 _('  bug reporting: %s\n'), extbuglink)



More information about the Mercurial-devel mailing list