Patchwork [2,of,5,v2] hghave: add checkrange function

login
register
mail settings
Submitter timeless@mozdev.org
Date April 1, 2016, 10:25 p.m.
Message ID <33d33a5d4a8a438aa7e7.1459549522@waste.org>
Download mbox | patch
Permalink /patch/14240/
State Changes Requested
Headers show

Comments

timeless@mozdev.org - April 1, 2016, 10:25 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1459515856 0
#      Fri Apr 01 13:04:16 2016 +0000
# Node ID 33d33a5d4a8a438aa7e7d0074964dd85865462d9
# Parent  0b49a4a6a7e2d139727fdf172f2242238733564b
hghave: add checkrange function
Pierre-Yves David - April 3, 2016, 8:51 p.m.
On 04/01/2016 03:25 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1459515856 0
> #      Fri Apr 01 13:04:16 2016 +0000
> # Node ID 33d33a5d4a8a438aa7e7d0074964dd85865462d9
> # Parent  0b49a4a6a7e2d139727fdf172f2242238733564b
> hghave: add checkrange function
>
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -22,6 +22,19 @@
>           return func
>       return decorator
>
> +def checkrange(name, desc, vers):

Can we get a docstring explaining whet this function is about? from 
later patch, it seems a way to automate version check, but the check 
still seems individual (not a range). I'm a bit confused.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -22,6 +22,19 @@ 
         return func
     return decorator
 
+def checkrange(name, desc, vers):
+    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': [],