changeset 46021:e402a45261db stable

extensions: gracefully warn when doing min version check with no local version After doing a `make clean`, I started getting cryptic failures to import extensions with the `minimumhgversion` attribute on py3: *** failed to import extension evolve: '>' not supported between instances of 'int' and 'NoneType' *** failed to import extension topic: '>' not supported between instances of 'int' and 'NoneType' This now handles the `(None, None)` tuple before comparing, and disables the extension with the same friendly message as in py2. Differential Revision: https://phab.mercurial-scm.org/D9363
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 21 Nov 2020 16:55:07 -0500
parents 210f9b8d7bbd
children cd7f36337741
files mercurial/extensions.py
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/extensions.py	Sat Nov 28 11:15:54 2020 +0900
+++ b/mercurial/extensions.py	Sat Nov 21 16:55:07 2020 -0500
@@ -222,13 +222,16 @@
     # extensions short circuit when loaded with a known incompatible version
     # of Mercurial.
     minver = getattr(mod, 'minimumhgversion', None)
-    if minver and util.versiontuple(minver, 2) > util.versiontuple(n=2):
-        msg = _(
-            b'(third party extension %s requires version %s or newer '
-            b'of Mercurial (current: %s); disabling)\n'
-        )
-        ui.warn(msg % (shortname, minver, util.version()))
-        return
+    if minver:
+        curver = util.versiontuple(n=2)
+
+        if None in curver or util.versiontuple(minver, 2) > curver:
+            msg = _(
+                b'(third party extension %s requires version %s or newer '
+                b'of Mercurial (current: %s); disabling)\n'
+            )
+            ui.warn(msg % (shortname, minver, util.version()))
+            return
     ui.log(b'extension', b'    - validating extension tables: %s\n', shortname)
     _validatetables(ui, mod)