dispatch: handle empty `testedwith` value in extension stable
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 04 Jan 2013 19:06:42 +0100
branchstable
changeset 18224 0f9013112eba
parent 18207 3b1005354440
child 18225 6a082e72df4e
child 18292 40185df018d7
dispatch: handle empty `testedwith` value in extension When extensions had an empty `testedwith` attribute the code tried to parse it and failed. As a result the actual error were shallowed by a This crash. We now treat empty strip as 'unknown'
mercurial/dispatch.py
tests/test-extension.t
--- a/mercurial/dispatch.py	Wed Jan 02 13:59:07 2013 +0100
+++ b/mercurial/dispatch.py	Fri Jan 04 19:06:42 2013 +0100
@@ -217,11 +217,11 @@
         ct = tuplever(compare)
         worst = None, ct, ''
         for name, mod in extensions.extensions():
-            testedwith = getattr(mod, 'testedwith', 'unknown')
+            testedwith = getattr(mod, 'testedwith', '')
             report = getattr(mod, 'buglink', _('the extension author.'))
-            if testedwith == 'unknown':
+            if not testedwith.strip():
                 # We found an untested extension. It's likely the culprit.
-                worst = name, testedwith, report
+                worst = name, 'unknown', report
                 break
             if compare not in testedwith.split() and testedwith != 'internal':
                 tested = [tuplever(v) for v in testedwith.split()]
--- a/tests/test-extension.t	Wed Jan 02 13:59:07 2013 +0100
+++ b/tests/test-extension.t	Fri Jan 04 19:06:42 2013 +0100
@@ -498,6 +498,16 @@
   ** Python * (glob)
   ** Mercurial Distributed SCM * (glob)
   ** Extensions loaded: throw
+empty declaration of supported version, extension complains:
+  $ echo "testedwith = ''" >> throw.py
+  $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
+  ** Unknown exception encountered with possibly-broken third-party extension throw
+  ** 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.
+  ** Python * (glob)
+  ** Mercurial Distributed SCM (*) (glob)
+  ** Extensions loaded: throw
 If the extension specifies a buglink, show that:
   $ echo 'buglink = "http://example.com/bts"' >> throw.py
   $ rm -f throw.pyc throw.pyo