[PATCH] mercurial: add debugextensions command (issue4676)

Matt Mackall mpm at selenic.com
Sat Sep 12 18:04:38 CDT 2015


On Thu, 2015-09-10 at 20:25 +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 a1d762cfc0428911f52b109d1c335a37ea24ff59
> # 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 the table with: extension name, import source,
> testedwith and buglink informations. If information about testedwith
> or buglink in given module is missing it prints "-" in appropriate
> column.

Interesting choice to use minirst tables here. Unfortunately,  I don't
think it's going to work out well for a lot of people because some of
the columns can be quite wide:

$ hg debugextensions 
============== =========================================== ============================= ===========================================
Extension name Import source                               Testedwith                    Buglink                                    
============== =========================================== ============================= ===========================================
purge          /home/mpm/hg/hgext/purge.pyc                internal                      -                                          
dbsh           /home/mpm/hg/contrib/debugshell.pyc         -                             -                                          
extdiff        /home/mpm/hg/hgext/extdiff.pyc              internal                      -                                          
gpg            /home/mpm/hg/hgext/gpg.pyc                  internal                      -                                          
hggit          /home/mpm/src/hg-git/hggit/__init__.pyc     2.8.2 3.0.1 3.1 3.2.2 3.3 3.4 https://bitbucket.org/durin42/hg-git/issues


That's way over 80 columns. I'm sure there are a lot of people with
100-character paths to their extensions as well. It's also not a very
good match to our usual output style.

Here's what I'd suggest:

$ hg debugextensions -q
purge
dbsh
extdiff
...

$ hg debugextensions
purge
dbsh (untested!)
hggit (3.4!)
...

$ hg debugextensions -v
purge
 location: ...
 tested with: internal
 bug reporting: http://bz.selenic.com
hggit
...

Sorting probably makes sense here. It might also make sense to use the
generic templating interface:

https://mercurial.selenic.com/wiki/GenericTemplatingPlan


> diff -r ea489d94e1dc -r a1d762cfc042 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
> @@ -2184,6 +2184,28 @@
>      for f in ctx.getfileset(expr):
>          ui.write("%s\n" % f)
>  
> + at command('debugextensions', [], norepo=True)
> +def debugextensions(ui):
> +    exts = extensions.extensions(ui)
> +    header = ["Extension name", "Import source", "Testedwith", "Buglink"]
> +    rows = [header]
> +    for extname, extmod in exts:
> +        extsource = extmod.__file__
> +        try:
> +            exttestedwith = extmod.testedwith
> +        except AttributeError:
> +            exttestedwith = "-"
> +        try:
> +            extbuglink = extmod.buglink
> +        except AttributeError:
> +            extbuglink = "-"
> +        rows.append([extname, extsource, exttestedwith, extbuglink])
> +
> +    if len(rows) > 1:
> +        rst = minirst.maketable(rows, header=True)
> +        table = ''.join(rst)
> +        ui.write(table)
> +
>  @command('debugfsinfo', [], _('[PATH]'), norepo=True)
>  def debugfsinfo(ui, path="."):
>      """show information detected about current filesystem"""
> diff -r ea489d94e1dc -r a1d762cfc042 tests/test-debugextensions.t
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/tests/test-debugextensions.t	Thu Sep 10 16:53:07 2015 +0200
> @@ -0,0 +1,21 @@
> +  $ hg debugextensions
> +
> +  $ cat >> $HGRCPATH <<EOF
> +  > [extensions]
> +  > color=
> +  > histedit=
> +  > patchbomb=
> +  > rebase=
> +  > mq=
> +  > EOF
> +
> +  $ hg debugextensions
> +  ==============*=====================*==========*======= (glob)
> +  Extension name*Import source        *Testedwith*Buglink (glob)
> +  ==============*=====================*==========*======= (glob)
> +  color          */hgext/color.pyc    *internal  *-       (glob)
> +  histedit       */hgext/histedit.pyc *internal  *-       (glob)
> +  patchbomb      */hgext/patchbomb.pyc*internal  *-       (glob)
> +  rebase         */hgext/rebase.pyc   *internal  *-       (glob)
> +  mq             */hgext/mq.pyc       *internal  *-       (glob)
> +  ==============*=====================*==========*======= (glob)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list