[PATCH] mercurial: add debugextensions command (issue4676)

liscju piotr.listkiewicz at gmail.com
Sun Sep 13 04:47:50 CDT 2015


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1441896787 -7200
#      Thu Sep 10 16:53:07 2015 +0200
# Node ID 9b8856e8bfa2d2a75006d1ebdcbbe98bb7424b6e
# 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 verbose is
specified it prints following information for every extension:
extension name, import source, testedwith and buglink informations.

diff -r ea489d94e1dc -r 9b8856e8bfa2 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,37 @@
     for f in ctx.getfileset(expr):
         ui.write("%s\n" % f)
 
+ at command('debugextensions', [], norepo=True)
+def debugextensions(ui, **opts):
+    exts = extensions.extensions(ui)
+    exts_infos = []
+    for extname, extmod in exts:
+        extsource = extmod.__file__
+        try:
+            exttestedwith = extmod.testedwith
+        except AttributeError:
+            exttestedwith = None
+        try:
+            extbuglink = extmod.buglink
+        except AttributeError:
+            extbuglink = None
+        exts_infos.append([extname, extsource, exttestedwith, extbuglink])
+
+    if len(exts_infos) > 0:
+        fm = ui.formatter('debugextensions', opts)
+        for row in exts_infos:
+            fm.startitem()
+            fm.write('Extension name', '%s\n', row[0])
+            fm.condwrite(ui.verbose,
+                         'Import source', '  location: %s\n', row[1])
+
+            fm.condwrite(ui.verbose and row[2],
+                         'Tested with', '  tested with: %s\n', row[2])
+
+            fm.condwrite(ui.verbose and row[3],
+                         'Bug link', '  bug reporting: %s\n', row[3])
+        fm.end()
+
 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
 def debugfsinfo(ui, path="."):
     """show information detected about current filesystem"""
diff -r ea489d94e1dc -r 9b8856e8bfa2 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,34 @@
+  $ hg debugextensions
+
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > color=
+  > histedit=
+  > patchbomb=
+  > rebase=
+  > mq=
+  > EOF
+
+  $ hg debugextensions
+  color
+  histedit
+  patchbomb
+  rebase
+  mq
+
+  $ hg debugextensions -v
+  color
+    location: */hgext/color.pyc (glob)
+    tested with: internal
+  histedit
+    location: */hgext/histedit.pyc (glob)
+    tested with: internal
+  patchbomb
+    location: */hgext/patchbomb.pyc (glob)
+    tested with: internal
+  rebase
+    location: */hgext/rebase.pyc (glob)
+    tested with: internal
+  mq
+    location: */hgext/mq.pyc (glob)
+    tested with: internal


More information about the Mercurial-devel mailing list