[PATCH V2] mercurial: add debugextensions command (issue4676)
liscju
piotr.listkiewicz at gmail.com
Tue Sep 22 08:39:31 UTC 2015
# 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.
diff -r ea489d94e1dc -r 5282acdf2c36 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,46 @@
localrevs = opts.get('local_head')
doit(localrevs, remoterevs)
+ at command('debugextensions', formatteropts, [], norepo=True)
+def debugextensions(ui, **opts):
+ '''show informations 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('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)
+
+ fm.condwrite(ui.verbose, 'import source',
+ ' location: %s\n', extsource)
+
+ fm.condwrite(ui.verbose, 'tested with',
+ ' tested with: %s\n', exttestedwith)
+
+ fm.condwrite(ui.verbose, 'bug link',
+ ' bug reporting: %s\n', extbuglink)
+
+ fm.end()
+
@command('debugfileset',
[('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
_('[-r REV] FILESPEC'))
diff -r ea489d94e1dc -r 5282acdf2c36 mercurial/formatter.py
--- a/mercurial/formatter.py Sat Aug 22 17:08:37 2015 -0700
+++ b/mercurial/formatter.py Thu Sep 10 16:53:07 2015 +0200
@@ -108,7 +108,7 @@
self._ui.write(cPickle.dumps(self._data))
def _jsonifyobj(v):
- if isinstance(v, tuple):
+ if isinstance(v, tuple) or isinstance(v, list):
return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
elif v is None:
return 'null'
diff -r ea489d94e1dc -r 5282acdf2c36 tests/test-completion.t
--- a/tests/test-completion.t Sat Aug 22 17:08:37 2015 -0700
+++ b/tests/test-completion.t Thu Sep 10 16:53:07 2015 +0200
@@ -80,6 +80,7 @@
debugdate
debugdirstate
debugdiscovery
+ debugextensions
debugfileset
debugfsinfo
debuggetbundle
@@ -239,6 +240,7 @@
debugdate: extended
debugdirstate: nodates, datesort
debugdiscovery: old, nonheads, ssh, remotecmd, insecure
+ debugextensions: template
debugfileset: rev
debugfsinfo:
debuggetbundle: head, common, type
diff -r ea489d94e1dc -r 5282acdf2c36 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,39 @@
+ $ hg debugextensions
+
+ $ cat >> $HGRCPATH <<EOF
+ > [extensions]
+ > color=
+ > histedit=
+ > patchbomb=
+ > rebase=
+ > mq=
+ > EOF
+
+ $ hg debugextensions
+ color
+ histedit
+ mq
+ patchbomb
+ rebase
+
+ $ hg debugextensions -v
+ color
+ location: */hgext/color.pyc (glob)
+ tested with: ['internal']
+ bug reporting: None
+ histedit
+ location: */hgext/histedit.pyc (glob)
+ tested with: ['internal']
+ bug reporting: None
+ mq
+ location: */hgext/mq.pyc (glob)
+ tested with: ['internal']
+ bug reporting: None
+ patchbomb
+ location: */hgext/patchbomb.pyc (glob)
+ tested with: ['internal']
+ bug reporting: None
+ rebase
+ location: */hgext/rebase.pyc (glob)
+ tested with: ['internal']
+ bug reporting: None
diff -r ea489d94e1dc -r 5282acdf2c36 tests/test-extension.t
--- a/tests/test-extension.t Sat Aug 22 17:08:37 2015 -0700
+++ b/tests/test-extension.t Thu Sep 10 16:53:07 2015 +0200
@@ -289,17 +289,23 @@
$ echo "debugextension = $debugpath" >> $HGRCPATH
$ hg help debugextension
- debugextension extension - only debugcommands
+ hg debugextensions
- no commands defined
+ show informations about active extensions
+
+ options:
+
+ (some details hidden, use --verbose to show complete help)
$ hg --verbose help debugextension
- debugextension extension - only debugcommands
+ hg debugextensions
- list of commands:
+ show informations about active extensions
- foo yet another foo command
+ options:
+
+ -T --template TEMPLATE display with template (EXPERIMENTAL)
global options ([+] can be repeated):
@@ -328,12 +334,13 @@
$ hg --debug help debugextension
- debugextension extension - only debugcommands
+ hg debugextensions
- list of commands:
+ show informations about active extensions
- debugfoobar yet another debug command
- foo yet another foo command
+ options:
+
+ -T --template TEMPLATE display with template (EXPERIMENTAL)
global options ([+] can be repeated):
@@ -546,20 +553,7 @@
Issue811: Problem loading extensions twice (by site and by user)
- $ debugpath=`pwd`/debugissue811.py
- $ cat > debugissue811.py <<EOF
- > '''show all loaded extensions
- > '''
- > from mercurial import cmdutil, commands, extensions
- > cmdtable = {}
- > command = cmdutil.command(cmdtable)
- > @command('debugextensions', [], 'hg debugextensions', norepo=True)
- > def debugextensions(ui):
- > "yet another debug command"
- > ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
- > EOF
$ cat <<EOF >> $HGRCPATH
- > debugissue811 = $debugpath
> mq =
> strip =
> hgext.mq =
@@ -570,9 +564,8 @@
(note that mq force load strip, also checking it's not loaded twice)
$ hg debugextensions
- debugissue811
+ mq
strip
- mq
For extensions, which name matches one of its commands, help
message should ask '-v -e' to get list of built-in aliases
diff -r ea489d94e1dc -r 5282acdf2c36 tests/test-help.t
--- a/tests/test-help.t Sat Aug 22 17:08:37 2015 -0700
+++ b/tests/test-help.t Thu Sep 10 16:53:07 2015 +0200
@@ -775,6 +775,8 @@
show the contents of the current dirstate
debugdiscovery
runs the changeset discovery protocol in isolation
+ debugextensions
+ show informations about active extensions
debugfileset parse and apply a fileset specification
debugfsinfo show information detected about current filesystem
debuggetbundle
More information about the Mercurial-devel
mailing list