hghave: add checkvers function
authortimeless <timeless@mozdev.org>
Fri, 01 Apr 2016 13:04:16 +0000
changeset 28758 44e076a12bd3
parent 28757 93bf61913f33
child 28759 2348ca49aaee
hghave: add checkvers function
tests/hghave.py
--- a/tests/hghave.py	Mon Apr 04 02:17:36 2016 +0000
+++ b/tests/hghave.py	Fri Apr 01 13:04:16 2016 +0000
@@ -23,6 +23,22 @@
         return func
     return decorator
 
+def checkvers(name, desc, vers):
+    """Registers a check function for each of a series of versions.
+
+    vers can be a list or an iterator"""
+    def decorator(func):
+        def funcv(v):
+            def f():
+                return func(v)
+            return f
+        for v in vers:
+            v = str(v)
+            f = funcv(v)
+            checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v)
+        return func
+    return decorator
+
 def checkfeatures(features):
     result = {
         'error': [],