mercurial/extensions.py
changeset 27142 060f83d219b9
parent 27116 0214cc0a0e97
child 27637 b502138f5faa
--- a/mercurial/extensions.py	Wed Nov 25 00:39:05 2015 +0000
+++ b/mercurial/extensions.py	Tue Nov 24 15:16:25 2015 -0800
@@ -101,6 +101,17 @@
             if ui.debugflag:
                 ui.traceback()
             mod = importh(name)
+
+    # Before we do anything with the extension, check against minimum stated
+    # compatibility. This gives extension authors a mechanism to have their
+    # 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):
+        ui.warn(_('(third party extension %s requires version %s or newer '
+                  'of Mercurial; disabling)\n') % (shortname, minver))
+        return
+
     _extensions[shortname] = mod
     _order.append(shortname)
     for fn in _aftercallbacks.get(shortname, []):