Restore override_log.py, whose docstring edit duplicated its code

This commit is contained in:
2026-10-22 01:11:35 +02:00
parent 9e4aebb3ff
commit b57dc461c6
-32
View File
@@ -45,38 +45,6 @@ def this_chunks(entry: LogLine, reflog: set[str], branch: str, on_default: typin
return entry.commit in reflog and (entry.branch == branch or not on_default(entry.commit))
@dataclasses.dataclass(frozen=True)
class LogLine:
"""One line of the log, its fields tab-separated in this order."""
at: str
branch: str
# The commit checked out when the override let its call through; empty on a branch with no commit yet.
commit: str
rule: str
reason: str
what: str
def line(self) -> str:
return "\t".join(" ".join(field.split()) for field in dataclasses.astuple(self)) + "\n"
def parsed_entry(line: str) -> LogLine | None:
fields = line.rstrip("\n").split("\t")
return LogLine(*fields) if len(fields) == len(dataclasses.fields(LogLine)) else None
def this_chunks(entry: LogLine, reflog: set[str], branch: str, on_default: typing.Callable[[str], bool]) -> bool:
"""Whether the override is the current branch's: its commit is in the branch's reflog, which holds every commit the branch has had. So:
- an override logged at c1 still counts after an amend or a rebase replaced c1 with c2;
- one logged under the branch's old name counts after `git branch -m`, which carries the reflog over;
- one logged on another branch, at a commit this reflog lacks, doesn't count;
- one logged at a default-branch commit counts only under this branch's own name, since every branch's reflog holds the default branch's commits."""
if entry.commit == "":
return True
# Such a line is one logged before the branch's first commit.
return entry.commit in reflog and (entry.branch == branch or not on_default(entry.commit))
@dataclasses.dataclass(frozen=True)
class Log:
path: pathlib.Path