compare-disco: move case parsing into its own function
authorPierre-Yves DAVID <pierre-yves.david@octobus.net>
Sat, 04 Jun 2022 19:10:51 +0200
changeset 49462 ef0b0f94d2e5
parent 49461 ebbaf6a77807
child 49463 5acbc550d987
compare-disco: move case parsing into its own function This is open the way to the next changeset that will allow to specify a list of heads.
contrib/perf-utils/compare-discovery-case
--- a/contrib/perf-utils/compare-discovery-case	Sat Jun 04 19:04:01 2022 +0200
+++ b/contrib/perf-utils/compare-discovery-case	Sat Jun 04 19:10:51 2022 +0200
@@ -97,6 +97,12 @@
 assert set(VARIANTS.keys()) == set(VARIANTS_KEYS)
 
 
+def parse_case(case):
+    case_type, case_args = case.split('-', 1)
+    case = (case_type,) + tuple(int(x) for x in case_args.split('-'))
+    return case
+
+
 def format_case(case):
     return '-'.join(str(s) for s in case)
 
@@ -210,8 +216,6 @@
         print(usage, file=sys.stderr)
         sys.exit(128)
     repo = argv[1]
-    local_case = argv[2].split('-')
-    local_case = (local_case[0],) + tuple(int(x) for x in local_case[1:])
-    remote_case = argv[3].split('-')
-    remote_case = (remote_case[0],) + tuple(int(x) for x in remote_case[1:])
+    local_case = parse_case(argv[2])
+    remote_case = parse_case(argv[3])
     sys.exit(compare(repo, local_case, remote_case, **kwargs))