comparison mercurial/extensions.py @ 45774: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 5d09a120b4be
children 27c23c8f14da 89a2afe31e82
comparison
equal deleted inserted replaced
45773:210f9b8d7bbd 45774:e402a45261db
220 # Before we do anything with the extension, check against minimum stated 220 # Before we do anything with the extension, check against minimum stated
221 # compatibility. This gives extension authors a mechanism to have their 221 # compatibility. This gives extension authors a mechanism to have their
222 # extensions short circuit when loaded with a known incompatible version 222 # extensions short circuit when loaded with a known incompatible version
223 # of Mercurial. 223 # of Mercurial.
224 minver = getattr(mod, 'minimumhgversion', None) 224 minver = getattr(mod, 'minimumhgversion', None)
225 if minver and util.versiontuple(minver, 2) > util.versiontuple(n=2): 225 if minver:
226 msg = _( 226 curver = util.versiontuple(n=2)
227 b'(third party extension %s requires version %s or newer ' 227
228 b'of Mercurial (current: %s); disabling)\n' 228 if None in curver or util.versiontuple(minver, 2) > curver:
229 ) 229 msg = _(
230 ui.warn(msg % (shortname, minver, util.version())) 230 b'(third party extension %s requires version %s or newer '
231 return 231 b'of Mercurial (current: %s); disabling)\n'
232 )
233 ui.warn(msg % (shortname, minver, util.version()))
234 return
232 ui.log(b'extension', b' - validating extension tables: %s\n', shortname) 235 ui.log(b'extension', b' - validating extension tables: %s\n', shortname)
233 _validatetables(ui, mod) 236 _validatetables(ui, mod)
234 237
235 _extensions[shortname] = mod 238 _extensions[shortname] = mod
236 _order.append(shortname) 239 _order.append(shortname)