dispatch: print the version of the extension being blamed in a bug report
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 27 Nov 2020 14:31:59 -0500
changeset 45951 c26cb33e5219
parent 45950 c7c1efdfd4de
child 45952 a2104b9b1787
dispatch: print the version of the extension being blamed in a bug report I don't know of a lot of extensions using this, but it seems like useful info in a bug report. Differential Revision: https://phab.mercurial-scm.org/D9437
mercurial/dispatch.py
tests/test-blackbox.t
tests/test-devel-warnings.t
tests/test-extension.t
--- a/mercurial/dispatch.py	Thu Nov 26 15:09:57 2020 -0500
+++ b/mercurial/dispatch.py	Fri Nov 27 14:31:59 2020 -0500
@@ -1253,7 +1253,7 @@
     # of date) will be clueful enough to notice the implausible
     # version number and try updating.
     ct = util.versiontuple(n=2)
-    worst = None, ct, b''
+    worst = None, ct, b'', b''
     if ui.config(b'ui', b'supportcontact') is None:
         for name, mod in extensions.extensions():
             # 'testedwith' should be bytes, but not all extensions are ported
@@ -1261,10 +1261,11 @@
             testedwith = stringutil.forcebytestr(
                 getattr(mod, 'testedwith', b'')
             )
+            version = extensions.moduleversion(mod)
             report = getattr(mod, 'buglink', _(b'the extension author.'))
             if not testedwith.strip():
                 # We found an untested extension. It's likely the culprit.
-                worst = name, b'unknown', report
+                worst = name, b'unknown', report, version
                 break
 
             # Never blame on extensions bundled with Mercurial.
@@ -1278,20 +1279,21 @@
             lower = [t for t in tested if t < ct]
             nearest = max(lower or tested)
             if worst[0] is None or nearest < worst[1]:
-                worst = name, nearest, report
+                worst = name, nearest, report, version
     if worst[0] is not None:
-        name, testedwith, report = worst
+        name, testedwith, report, version = worst
         if not isinstance(testedwith, (bytes, str)):
             testedwith = b'.'.join(
                 [stringutil.forcebytestr(c) for c in testedwith]
             )
+        extver = version or _(b"(version N/A)")
         warning = _(
             b'** Unknown exception encountered with '
-            b'possibly-broken third-party extension %s\n'
+            b'possibly-broken third-party extension %s %s\n'
             b'** which supports versions %s of Mercurial.\n'
             b'** Please disable %s and try your action again.\n'
             b'** If that fixes the bug please report it to %s\n'
-        ) % (name, testedwith, name, stringutil.forcebytestr(report))
+        ) % (name, extver, testedwith, name, stringutil.forcebytestr(report))
     else:
         bugtracker = ui.config(b'ui', b'supportcontact')
         if bugtracker is None:
--- a/tests/test-blackbox.t	Thu Nov 26 15:09:57 2020 -0500
+++ b/tests/test-blackbox.t	Fri Nov 27 14:31:59 2020 -0500
@@ -482,7 +482,7 @@
 #endif
 
   $ head -1 .hg/blackbox.log
-  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock (version N/A)
   $ tail -2 .hg/blackbox.log
   RuntimeError: raise
   
--- a/tests/test-devel-warnings.t	Thu Nov 26 15:09:57 2020 -0500
+++ b/tests/test-devel-warnings.t	Fri Nov 27 14:31:59 2020 -0500
@@ -310,7 +310,7 @@
 Test programming error failure:
 
   $ hg buggytransaction 2>&1 | egrep -v '^  '
-  ** Unknown exception encountered with possibly-broken third-party extension buggylocking
+  ** Unknown exception encountered with possibly-broken third-party extension buggylocking (version N/A)
   ** which supports versions unknown of Mercurial.
   ** Please disable buggylocking and try your action again.
   ** If that fixes the bug please report it to the extension author.
@@ -322,7 +322,7 @@
   *ProgrammingError: transaction requires locking (glob)
 
   $ hg programmingerror 2>&1 | egrep -v '^  '
-  ** Unknown exception encountered with possibly-broken third-party extension buggylocking
+  ** Unknown exception encountered with possibly-broken third-party extension buggylocking (version N/A)
   ** which supports versions unknown of Mercurial.
   ** Please disable buggylocking and try your action again.
   ** If that fixes the bug please report it to the extension author.
--- a/tests/test-extension.t	Thu Nov 26 15:09:57 2020 -0500
+++ b/tests/test-extension.t	Fri Nov 27 14:31:59 2020 -0500
@@ -1415,7 +1415,7 @@
 
 No declared supported version, extension complains:
   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension throw
+  ** Unknown exception encountered with possibly-broken third-party extension throw 1.0.0
   ** which supports versions unknown of Mercurial.
   ** Please disable throw and try your action again.
   ** If that fixes the bug please report it to the extension author.
@@ -1427,7 +1427,7 @@
 the value is improperly a str instead of bytes):
   $ echo "testedwith = ''" >> throw.py
   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension throw
+  ** Unknown exception encountered with possibly-broken third-party extension throw 1.0.0
   ** which supports versions unknown of Mercurial.
   ** Please disable throw and try your action again.
   ** If that fixes the bug please report it to the extension author.
@@ -1441,7 +1441,7 @@
   $ rm -f throw.pyc throw.pyo
   $ rm -Rf __pycache__
   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension throw
+  ** Unknown exception encountered with possibly-broken third-party extension throw 1.0.0
   ** which supports versions unknown of Mercurial.
   ** Please disable throw and try your action again.
   ** If that fixes the bug please report it to http://example.com/bts
@@ -1458,7 +1458,7 @@
   $ rm -Rf __pycache__
   $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
   >   throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension older
+  ** Unknown exception encountered with possibly-broken third-party extension older (version N/A)
   ** which supports versions 1.9 of Mercurial.
   ** Please disable older and try your action again.
   ** If that fixes the bug please report it to the extension author.
@@ -1472,7 +1472,7 @@
   $ rm -Rf __pycache__
   $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
   >   throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension older
+  ** Unknown exception encountered with possibly-broken third-party extension older (version N/A)
   ** which supports versions 1.9 of Mercurial.
   ** Please disable older and try your action again.
   ** If that fixes the bug please report it to the extension author.
@@ -1486,7 +1486,7 @@
   $ rm -Rf __pycache__
   $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
   >   throw 2>&1 | egrep '^\*\*'
-  ** Unknown exception encountered with possibly-broken third-party extension throw
+  ** Unknown exception encountered with possibly-broken third-party extension throw 1.0.0
   ** which supports versions 2.1 of Mercurial.
   ** Please disable throw and try your action again.
   ** If that fixes the bug please report it to http://example.com/bts