Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions patchoulene/src/patchoulene/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import difflib
import json
import os
import pathlib
import re
import shlex
import subprocess
import sys

from . import b4
from .message import *
from .git import GitCommit, GitRepo
from .message import *


def series_entry(c: GitCommit):
Expand Down Expand Up @@ -269,7 +265,7 @@ def msg_possible_match(

msgs = [f"... the replacement of patch {possible}?"]
if not is_id_match:
msgs.append(f"* (weak match)")
msgs.append("* (weak match)")
msgs.append(f' "{old_subject}"{is_identical}')

return "\n".join(msgs)
Expand Down Expand Up @@ -302,7 +298,7 @@ def msg_merged(commit: GitCommit, primary: str) -> str:
if db.get(primary, {}).get("replacement", None) is not None:
continue

possible_matches = set(pid for pid in upstream[1:] if pid in db)
possible_matches = {pid for pid in upstream[1:] if pid in db}
possible_matches |= set(by_subject.get(clean, []))
possible_matches -= {primary}

Expand Down Expand Up @@ -403,7 +399,7 @@ def msg_replacement_header(commit: GitCommit) -> str:
msgs = [
f'Commit {commit.commit[:12]} ("{clean}"):',
f" {dim(primary)}",
f" has replacement:",
" has replacement:",
]

return "\n".join(msgs)
Expand Down Expand Up @@ -448,12 +444,12 @@ def do_mail_check(db: dict[str, dict]) -> list[dict[str, list[dict[str, str]]]]:
def msg_thread_replacement(
this_thread: list[b4.PatchHeader], latest_thread: list[b4.PatchHeader]
) -> str:
msgs = [f"Patches:"]
msgs = ["Patches:"]
for m in this_thread:
msgs.append(f" {m.clean_subject()}")
msgs.append(f" https://patch.msgid.link/{m.message_id()}")

msgs.append(f"... may have replacement:")
msgs.append("... may have replacement:")
for m in latest_thread:
msgs.append(f" {m.clean_subject()}")
msgs.append(f" https://patch.msgid.link/{m.message_id()}")
Expand Down Expand Up @@ -568,7 +564,7 @@ def do_mail_match(data: list[dict]):
subj_b = replacement[idxb].subject()
print(f" -> (B{idxb + 1}) {subj_b}", file=sys.stderr)
else:
print(f" (no replacement)", file=sys.stderr)
print(" (no replacement)", file=sys.stderr)

print(file=sys.stderr)
print("Replacement version:", file=sys.stderr)
Expand Down Expand Up @@ -669,7 +665,7 @@ def do_mail_match(data: list[dict]):

match key:
case "y":
print(f"(Accepted)", file=sys.stderr)
print("(Accepted)", file=sys.stderr)
for i in range(len(current)):
row = matrix[i]

Expand All @@ -692,7 +688,7 @@ def do_mail_match(data: list[dict]):
db[cur_pid]["replacement"] = rids
break
case "n":
print(f"(Ignored)", file=sys.stderr)
print("(Ignored)", file=sys.stderr)
break
case "c":
for i in range(len(current)):
Expand Down Expand Up @@ -764,7 +760,7 @@ def main():
"subject": clean,
}

id_matches = set(pid for pid in guess[1:] if pid in db)
id_matches = {pid for pid in guess[1:] if pid in db}
possible_matches = id_matches | set(by_subject.get(clean, []))
possible_matches -= {primary}

Expand All @@ -785,7 +781,7 @@ def main():
print(f' "{clean}"', file=sys.stderr)
print(f"... the replacement of patch {possible}?", file=sys.stderr)
if possible not in id_matches:
print(f"* (weak match)", file=sys.stderr)
print("* (weak match)", file=sys.stderr)
print(f' "{old_subject}"{is_identical}', file=sys.stderr)
if prompt_yn():
db[possible]["replacement"] = primary
Expand All @@ -803,5 +799,5 @@ def main():
write_patch_db(db)

case _:
print(f"Bad usage", file=sys.stderr)
print("Bad usage", file=sys.stderr)
sys.exit(1)
4 changes: 1 addition & 3 deletions patchoulene/src/patchoulene/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import shlex
import subprocess

from .message import message_subject, clean_subject

RE_HASH_LIKE = re.compile(r"[0-9a-f]+")


Expand All @@ -18,7 +16,7 @@ def __init__(self, commit: str, message: str):
assert RE_HASH_LIKE.fullmatch(self.commit)

def __repr__(self) -> str:
return f"GitCommit(commit={repr(self.commit)}, message={repr(self.message)})"
return f"GitCommit(commit={self.commit!r}, message={self.message!r})"


class GitRepo:
Expand Down