diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -224,8 +224,12 @@ minver = getattr(mod, 'minimumhgversion', None) if minver: curver = util.versiontuple(n=2) + extmin = util.versiontuple(minver, 2) - if None in curver or util.versiontuple(minver, 2) > curver: + if None in extmin: + extmin = (extmin[0] or 0, extmin[1] or 0) + + if None in curver or extmin > curver: msg = _( b'(third party extension %s requires version %s or newer ' b'of Mercurial (current: %s); disabling)\n' diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -1692,6 +1692,25 @@ $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' [1] +Don't explode on py3 with a bad version number + + $ cat > minversion4.py << EOF + > from mercurial import util + > util.version = lambda: b'3.5' + > minimumhgversion = b'3' + > EOF + $ hg --config extensions.minversion=minversion4.py version -v + Mercurial Distributed SCM (version 3.5) + (see https://mercurial-scm.org for more information) + + Copyright (C) 2005-* Olivia Mackall and others (glob) + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Enabled extensions: + + minversion external + Restore HGRCPATH $ HGRCPATH=$ORGHGRCPATH