Patchwork D9363: extensions: gracefully warn when doing min version check with no local version

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2020, 9:59 p.m.
Message ID <differential-rev-PHID-DREV-3gq376vafopl3qskbrmv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47642/
State Superseded
Headers show

Comments

phabricator - Nov. 21, 2020, 9:59 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9363

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -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)