[PATCH 3 of 6 v3] hghave: add checkvers function

timeless timeless at mozdev.org
Sun Apr 3 22:20:51 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1459515856 0
#      Fri Apr 01 13:04:16 2016 +0000
# Node ID ceaa098476253c392435f2d62b4bca259e3adb30
# Parent  458b58dfd3ff86e2c27beb852b529b249fb6a467
hghave: add checkvers function

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -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': [],


More information about the Mercurial-devel mailing list