perf-util: add an helper revset to use the same spec as the case search script
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 16 Mar 2021 12:52:23 +0100
changeset 46772 63a3941d9847
parent 46771 6b26e6432554
child 46773 d13afdd1f6e2
perf-util: add an helper revset to use the same spec as the case search script This make result of the searcher script easier to use. Differential Revision: https://phab.mercurial-scm.org/D10228
contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py	Mon Mar 15 18:01:42 2021 +0100
+++ b/contrib/perf-utils/subsetmaker.py	Tue Mar 16 12:52:23 2021 +0100
@@ -18,6 +18,37 @@
 revsetpredicate = registrar.revsetpredicate()
 
 
+@revsetpredicate(b'subsetspec("<spec>")')
+def subsetmarkerspec(repo, subset, x):
+    """use a shorthand spec as used by search-discovery-case
+
+    Supported format are:
+
+    - "scratch-count-seed": not scratch(all(), count, "seed")
+    - "randomantichain-seed": ::randomantichain(all(), "seed")
+    - "rev-REV": "::REV"
+    """
+    args = revsetlang.getargs(
+        x, 0, 1, _(b'subsetspec("spec") required an argument')
+    )
+
+    spec = revsetlang.getstring(args[0], _(b"spec should be a string"))
+    case = spec.split(b'-')
+    t = case[0]
+    if t == b'scratch':
+        spec_revset = b'not scratch(all(), %s, "%s")' % (case[1], case[2])
+    elif t == b'randomantichain':
+        spec_revset = b'::randomantichain(all(), "%s")' % case[1]
+    elif t == b'rev':
+        spec_revset = b'::%d' % case[1]
+    else:
+        assert False, spec
+
+    selected = repo.revs(spec_revset)
+
+    return selected & subset
+
+
 @revsetpredicate(b'scratch(REVS, <count>, [seed])')
 def scratch(repo, subset, x):
     """randomly remove <count> revision from the repository top