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

Yuya Nishihara yuya at tcha.org
Tue Sep 22 08:11:23 CDT 2015


On Tue, 22 Sep 2015 10:39:31 +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 5282acdf2c3628065581169c89a233f9da001655
> # 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.

I think the functionality is good.
A couple of comments about the formatting:

> +        if ui.quiet or ui.verbose:
> +            fm.write('extension name', '%s\n', extname)
> +        else:
> +            fm.write('extension name', '%s', extname)
> +            if not exttestedwith:
> +                fm.write('tested with', ' (untested!)\n')
> +            else:
> +                if exttestedwith == ['internal'] or \
> +                                util.version() in exttestedwith:
> +                    fm.write('tested with', '\n')
> +                else:
> +                    lasttestedversion = exttestedwith[-1]
> +                    fm.write('tested with', ' (%s!)\n',
> +                             lasttestedversion)

This 'tested with' field will be overwritten by the subsequent condwrite().
We could

 a) suppress it in machine-readable and templated output: use fm.plain()
 b) or give different field name

> +        fm.condwrite(ui.verbose, 'tested with',
> +                 '  tested with: %s\n', exttestedwith)
> +


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

It should be something like this:

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

because

 - we probably don't want to see raw representation like "None" in plain output
 - plain output should be translated, so wrap it by _()
 - field names are space-separated list, and they are used as template keywords,
   e.g. -T '{name} ({testedwith})\n  <{buglink}>\n'

> +  $ hg debugextensions -v
> +  color
> +    location: */hgext/color.pyc (glob)
> +    tested with: ['internal']
> +    bug reporting: None

Can we avoid raw list representation "['...']" ?


More information about the Mercurial-devel mailing list