# HG changeset patch # User Matt Harbison # Date 2020-11-27 19:31:59 # Node ID c26cb33e5219c1e402922ac5214061c53191dd5d # Parent c7c1efdfd4dec044df57dd7f477e47165b576927 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 diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -1253,7 +1253,7 @@ def _exceptionwarning(ui): # 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 @@ def _exceptionwarning(ui): 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 @@ def _exceptionwarning(ui): 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: diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -482,7 +482,7 @@ blackbox should work if repo.ui.log is n #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 diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t +++ b/tests/test-devel-warnings.t @@ -310,7 +310,7 @@ Stripping from a transaction 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 @@ Test programming error failure: *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. diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -1415,7 +1415,7 @@ accessed. 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 @@ empty declaration of supported version, 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 @@ improperly a str instead of bytes): $ 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 @@ If the extensions declare outdated versi $ 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 @@ One extension only tested with older, on $ 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 @@ Older extension is tested with current v $ 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