Patchwork debug: move extensions debug behind a dedicated flag

login
register
mail settings
Submitter Boris Feld
Date July 16, 2018, 4:24 p.m.
Message ID <ae4c03e746f683769276.1531758250@FB-lair>
Download mbox | patch
Permalink /patch/32863/
State Accepted
Headers show

Comments

Yuya Nishihara - July 17, 2018, 1:39 p.m.
On Tue, 17 Jul 2018 06:33:56 -0700, Martin von Zweigbergk wrote:
> > > >> # HG changeset patch
> > > >> # User Boris Feld <boris.feld@octobus.net>
> > > >> # Date 1531756950 -7200
> > > >> #      Mon Jul 16 18:02:30 2018 +0200
> > > >> # Node ID ae4c03e746f6837692762fe488991b64008efd3e
> > > >> # Parent  3c569172848d329a81b1420d7cd8a5549b48f25f
> > > >> # EXP-Topic extdebug
> > > >> # Available At https://bitbucket.org/octobus/mercurial-devel/
> > > >> #              hg pull https://bitbucket.org/octobus/mercurial-devel/
> > -r
> > > >> ae4c03e746f6
> > > >> debug: move extensions debug behind a dedicated flag

> > > I see. I think `hg id --debug` is actually somewhat frequently (there are
> > > at least 30 instances in our test cases), so I thought you wanted to
> > > preserve that behavior.
> >
> > "hg log --debug" is another example of non-debug --debug option, which
> > can't
> > be simply translated to a new flag. Hiding extension debug message seems
> > better.
> >
> 
> I agree, I just misinterpreted the commit message. Feel free to queue

Queued, thanks.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -372,6 +372,9 @@  coreconfigitem('devel', 'user.obsmarker'
 coreconfigitem('devel', 'warn-config-unknown',
     default=None,
 )
+coreconfigitem('devel', 'debug.extensions',
+    default=False,
+)
 coreconfigitem('devel', 'debug.peer-request',
     default=False,
 )
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -123,10 +123,11 @@  def _importext(name, path=None, reportfu
 def _reportimporterror(ui, err, failed, next):
     # note: this ui.debug happens before --debug is processed,
     #       Use --config ui.debug=1 to see them.
-    ui.debug('could not import %s (%s): trying %s\n'
-             % (failed, stringutil.forcebytestr(err), next))
-    if ui.debugflag:
-        ui.traceback()
+    if ui.configbool('devel', 'debug.extensions'):
+        ui.debug('could not import %s (%s): trying %s\n'
+                 % (failed, stringutil.forcebytestr(err), next))
+        if ui.debugflag:
+            ui.traceback()
 
 def _rejectunicode(name, xs):
     if isinstance(xs, (list, set, tuple)):
diff --git a/tests/test-bad-extension.t b/tests/test-bad-extension.t
--- a/tests/test-bad-extension.t
+++ b/tests/test-bad-extension.t
@@ -72,10 +72,9 @@  names of extensions failed to load can b
   $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS'
   BADEXTS: badext badext2
 
-show traceback for ImportError of hgext.name if debug is set
-(note that --debug option isn't applied yet when loading extensions)
+show traceback for ImportError of hgext.name if devel.debug.extensions is set
 
-  $ (hg help help --traceback --config ui.debug=yes 2>&1) \
+  $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \
   > | grep -v '^ ' \
   > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import'
   *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow