# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1556409016 -7200
#      Sun Apr 28 01:50:16 2019 +0200
# Node ID 3ce8a2515d8a2308b25005642325721457a7957c
# Parent  f716863d66c059ff61e1e6c0b40abf711578b0c7
upgrade-reference: explicitly detect benchrepo file with repo-prefix

Explicitly detecting this older format will help use do have improve behavior
when upgrading a reference repository that already have a "repo-prefix" entry.

diff --git a/repo-scripts/upgrade-reference b/repo-scripts/upgrade-reference
--- a/repo-scripts/upgrade-reference
+++ b/repo-scripts/upgrade-reference
@@ -51,10 +51,13 @@
     benchrepo_data = read_yaml(benchrepo_path)
 
     repo_id = benchrepo_data["reference-repo"]["id"]
-    # Support old benchrepo files without repo-prefix
-    old_repo_prefix = benchrepo_data["reference-repo"].get(
-        "repo-prefix", repo_id
-    )
+
+    hadprefix = True
+    old_repo_prefix = benchrepo_data["reference-repo"].get("repo-prefix")
+    if old_repo_prefix is None:
+        # Support old benchrepo files without repo-prefix
+        hadprefix = False
+        old_repo_prefix = repo_id
 
     # Compute the new stats
     print("Gathering the new benchrepo data.")