Lines Matching full:rev
57 class Rev(NamedTuple("Rev", (("branch", str), ("number", int)))): class
61 def parse(rev: str) -> "Rev":
62 """Parses a Rev from the given string.
71 if rev.startswith("r"):
73 rev_string = rev[1:]
75 match = re.match(r"\((.+), r(\d+)\)", rev)
77 raise ValueError("%r isn't a valid revision" % rev)
81 return Rev(branch=branch_name, number=int(rev_string))
134 def translate_sha_to_rev(llvm_config: LLVMConfig, sha_or_ref: str) -> Rev:
135 """Translates a sha or git ref to a Rev."""
141 ["git", "rev-parse", "--revs-only", sha_or_ref, "--"],
156 "rev-list",
165 return Rev(branch=MAIN_BRANCH, number=count + base_rev)
175 return Rev(branch=MAIN_BRANCH, number=merge_base_number)
180 "rev-list",
220 return Rev(branch=candidates[0], number=revision_number)
262 def translate_prebase_rev_to_sha(llvm_config: LLVMConfig, rev: Rev) -> str: argument
263 """Translates a Rev to a SHA.
265 This function assumes that the given rev refers to a commit that's an
271 looking_for = f"llvm-svn: {rev.number}"
298 raise ValueError(f"No commit with revision {rev} found")
316 child_sha: A child of `parent_sha` to find a rev on.
335 "rev-list",
360 "rev-parse",
369 def translate_rev_to_sha(llvm_config: LLVMConfig, rev: Rev) -> str: argument
370 """Translates a Rev to a SHA.
372 Raises a ValueError if the given Rev doesn't exist in the given config.
374 branch, number = rev
377 ["git", "rev-parse", "--revs-only", f"{llvm_config.remote}/{branch}"],
404 return translate_prebase_rev_to_sha(llvm_config, rev)
431 assert False, "Couldn't find a base SHA for a rev on main?"
440 ["git", "rev-parse", "--show-toplevel"],
460 "--sha", help="A git SHA (or ref) to convert to a rev"
462 sha_or_rev.add_argument("--rev", help="A rev to convert into a sha")
480 rev = translate_sha_to_rev(config, opts.sha)
481 print(rev)
483 sha = translate_rev_to_sha(config, Rev.parse(opts.rev))