aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xllvm_tools/git_llvm_rev.py5
-rwxr-xr-xllvm_tools/git_llvm_rev_test.py6
2 files changed, 8 insertions, 3 deletions
diff --git a/llvm_tools/git_llvm_rev.py b/llvm_tools/git_llvm_rev.py
index c8c1505c..b62b26e2 100755
--- a/llvm_tools/git_llvm_rev.py
+++ b/llvm_tools/git_llvm_rev.py
@@ -183,6 +183,11 @@ def translate_sha_to_rev(llvm_config: LLVMConfig, sha_or_ref: str) -> Rev:
raise ValueError(
f'No viable branches found from {llvm_config.remote} with {sha}')
+ # It seems that some `origin/release/.*` branches have
+ # `origin/upstream/release/.*` equivalents, which is... awkward to deal with.
+ # Prefer the latter, since that seems to have newer commits than the former.
+ # Technically n^2, but len(elements) should be like, tens in the worst case.
+ candidates = [x for x in candidates if f'upstream/{x}' not in candidates]
if len(candidates) != 1:
raise ValueError(
f'Ambiguity: multiple branches from {llvm_config.remote} have {sha}: '
diff --git a/llvm_tools/git_llvm_rev_test.py b/llvm_tools/git_llvm_rev_test.py
index 74280c5d..d05093a8 100755
--- a/llvm_tools/git_llvm_rev_test.py
+++ b/llvm_tools/git_llvm_rev_test.py
@@ -93,7 +93,7 @@ class Test(unittest.TestCase):
def test_zz_branch_revs_work_after_merge_points_and_svn_cutoff(self) -> None:
# Arbitrary 9.x commit without an attached llvm-svn: value.
sha = self.rev_to_sha_with_round_trip(
- git_llvm_rev.Rev(branch='release/9.x', number=366670))
+ git_llvm_rev.Rev(branch='upstream/release/9.x', number=366670))
self.assertEqual(sha, '4e858e4ac00b59f064da4e1f7e276916e7d296aa')
def test_zz_branch_revs_work_at_merge_points(self) -> None:
@@ -108,7 +108,7 @@ class Test(unittest.TestCase):
# branch, we'll pick main for this. That's fine.
sha = git_llvm_rev.translate_rev_to_sha(
get_llvm_config(),
- git_llvm_rev.Rev(branch='release/9.x', number=rev_number))
+ git_llvm_rev.Rev(branch='upstream/release/9.x', number=rev_number))
self.assertEqual(sha, backing_sha)
def test_zz_branch_revs_work_after_merge_points(self) -> None:
@@ -117,7 +117,7 @@ class Test(unittest.TestCase):
# ours, and are therefore untrustworthy. The commit for this *does* have a
# different `llvm-svn:` string than we should have.
sha = self.rev_to_sha_with_round_trip(
- git_llvm_rev.Rev(branch='release/9.x', number=366427))
+ git_llvm_rev.Rev(branch='upstream/release/9.x', number=366427))
self.assertEqual(sha, '2cf681a11aea459b50d712abc7136f7129e4d57f')