# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1665442695 -7200
#      Tue Oct 11 00:58:15 2022 +0200
# Node ID 1ffffb032034543293a9b80fb76f6403d66f56dc
# Parent  617cfa829add86f337868c1baeb2779caeb36b1f
hg-perf-ext: add a new `compatible-revision-range` constraints

This will be useful to avoid running benchmark with incompatible revision.

diff --git a/docs/benchmarks.rst b/docs/benchmarks.rst
--- a/docs/benchmarks.rst
+++ b/docs/benchmarks.rst
@@ -156,6 +156,10 @@
   Target repository must have at least that many visible revision for this
   benchmark to run.
 
+- `compatible-revision-range=<revset>`:
+
+  The range of revision compatible with this changes. 
+
 
 variants
 --------
diff --git a/python-libs/poulpe/benchmarks.py b/python-libs/poulpe/benchmarks.py
--- a/python-libs/poulpe/benchmarks.py
+++ b/python-libs/poulpe/benchmarks.py
@@ -31,6 +31,14 @@
     else:
         core['graph']['visible-revision-count'] = min(new_revs, core_revs)
 
+    core_range = core.get('compatible-revision-range')
+    new_range = new.get('compatible-revision-range')
+    if new_range is not None:
+        if core_range is None:
+            core['compatible-revision-range'] = new_range
+        else:
+            rev_range = f"({core_range}) and ({new_range})"
+            core['compatible-revision-range'] = rev_range
 
 def get_benchmark(path_def):
     """get a benchmark from path applying possible variant selection on the way
diff --git a/suites/hg/scheduling/auto-cases b/suites/hg/scheduling/auto-cases
--- a/suites/hg/scheduling/auto-cases
+++ b/suites/hg/scheduling/auto-cases
@@ -150,6 +150,11 @@
             return False # we can't know
         if min_revs > revs:
             return False
+    rev_range = constraints.get('compatible-revision-range')
+    if rev_range is not None:
+        compatible = list_mercurial_hashes(base_dir, rev_range)
+        if changeset not in compatible:
+            return False
     return True