Lines Matching +full:- +full:- +full:revert
2 # -*- coding: utf-8 -*-
3 # ===----------------------------------------------------------------------===##
7 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 # ===----------------------------------------------------------------------===##
19 commit history (where `a -> b` notes that `b` is a direct child of `a`):
21 123abc -> 223abc -> 323abc -> 423abc -> 523abc
23 And where 423abc is a revert of 223abc, this revert is considered to be 'across'
24 323abc. More generally, a revert A of a parent commit B is considered to be
27 Please note that revert detection in general is really difficult, since merge
61 # Some lack that entirely, while others have many of them specified in ad-hoc
68 def _try_parse_reverts_from_commit_message(commit_message: str) -> List[str]:
73 r"This reverts commit ([a-f0-9]{40})\b", commit_message
77 initial_revert = re.match(r'Revert ([a-f0-9]{6,}) "', first_line)
83 def _stream_stdout(command: List[str]) -> Generator[str, None, None]:
85 command, stdout=subprocess.PIPE, encoding="utf-8", errors="replace"
91 def _resolve_sha(git_dir: str, sha: str) -> str:
96 ["git", "-C", git_dir, "rev-parse", sha],
97 encoding="utf-8",
113 ) -> Iterable[_LogEntry]:
117 "-C",
122 "--format=" + sep + "%n%H%n%B%n",
153 def _shas_between(git_dir: str, base_ref: str, head_ref: str) -> Iterable[str]:
156 "-C",
158 "rev-list",
159 "--first-parent",
165 def _rev_parse(git_dir: str, ref: str) -> str:
167 ["git", "-C", git_dir, "rev-parse", ref],
168 encoding="utf-8",
172 Revert = NamedTuple( variable
173 "Revert",
181 def _find_common_parent_commit(git_dir: str, ref_a: str, ref_b: str) -> str:
184 ["git", "-C", git_dir, "merge-base", ref_a, ref_b],
185 encoding="utf-8",
189 def find_reverts(git_dir: str, across_ref: str, root: str) -> List[Revert]:
235 ["git", "-C", git_dir, "cat-file", "-t", reverted_sha],
236 encoding="utf-8",
249 all_reverts.append(Revert(sha, reverted_sha))
253 "%s claims to revert %s -- which isn't a commit -- %s",
266 def _main() -> None:
275 "-C", "--git_dir", default=".", help="Git directory to use."
280 parser.add_argument("--debug", action="store_true")
282 "-u",
283 "--review_url",
301 for revert in find_reverts(opts.git_dir, opts.base_ref, root):
302 if revert not in seen_reverts:
303 seen_reverts.add(revert)
304 all_reverts.append(revert)
306 for revert in all_reverts:
308 f"https://reviews.llvm.org/rG{revert.sha}"
310 else revert.sha
313 f"https://reviews.llvm.org/rG{revert.reverted_sha}"
315 else revert.reverted_sha
317 print(f"{sha_fmt} claims to revert {reverted_sha_fmt}")