From 0bf1b0c344ed335ede41cb61842513be0de97916 Mon Sep 17 00:00:00 2001 From: Vivian Wang Date: Wed, 26 Aug 2026 10:13:03 +0800 Subject: [PATCH 1/3] tools: patchoulene: record: Ignore commits with replacement This can happen if a commit was reverted and a new version was posted later. In this case, the database would the new patch as the replacement, and later record invocations would ignore this commit Signed-off-by: Vivian Wang --- patchoulene/src/patchoulene/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/patchoulene/src/patchoulene/__init__.py b/patchoulene/src/patchoulene/__init__.py index ff2773d..c9e4afd 100644 --- a/patchoulene/src/patchoulene/__init__.py +++ b/patchoulene/src/patchoulene/__init__.py @@ -295,6 +295,10 @@ def msg_merged(commit: GitCommit, primary: str) -> str: primary = upstream[0] clean = clean_subject(c.message) + # Don't bother if upstream commit has replacement, to avoid cycles. + 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 |= set(by_subject.get(clean, [])) possible_matches -= {primary} From 63b5daba8b0d62b4e1cbd21d93e0cecae92aa47d Mon Sep 17 00:00:00 2001 From: Vivian Wang Date: Wed, 26 Aug 2026 10:33:07 +0800 Subject: [PATCH 2/3] tools: patchoulene: diff: Mark intra-series replacements If a patch in rev1 was removed because it was already replaced by some other patch in rev1, mark the replacement as "~" instead of "+" to indicate this special case. Signed-off-by: Vivian Wang --- patchoulene/src/patchoulene/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patchoulene/src/patchoulene/__init__.py b/patchoulene/src/patchoulene/__init__.py index c9e4afd..65392c3 100644 --- a/patchoulene/src/patchoulene/__init__.py +++ b/patchoulene/src/patchoulene/__init__.py @@ -205,7 +205,8 @@ def do_diff_commits( print(f' {prefix} "{clean_subject(c.message)}"') print(f" - {primary}") for g in gs: - print(f" + [{patch_num[g]}] {g}") + kind = "~" if g in cs1 else "+" + print(f" {kind} [{patch_num[g]}] {g}") for m, base in ms: print(f" in {base} ({m})") else: @@ -226,7 +227,8 @@ def do_diff_commits( continue if primary in replaces: print(f' [{patch_num[primary]}] Replacement "{clean_subject(c.message)}"') - print(f" + {primary}") + kind = "~" if primary in cs1 else "+" + print(f" {kind} {primary}") for r in sorted(replaces[primary], key=lambda r: patch_num[r]): print(f" - [{patch_num[r]}] {r}") else: From 175aee0e680fce7546db2f9cb416ced26c4f8a67 Mon Sep 17 00:00:00 2001 From: Vivian Wang Date: Fri, 28 Aug 2026 15:43:22 +0800 Subject: [PATCH 3/3] tools: patchoulene: diff: Ignore merged if has replacement If a patch has both merged and replacement, then this is probably a reverted patch, so disregard merged versions for the purposes of comparison. Signed-off-by: Vivian Wang --- patchoulene/src/patchoulene/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/patchoulene/src/patchoulene/__init__.py b/patchoulene/src/patchoulene/__init__.py index 65392c3..d3fa683 100644 --- a/patchoulene/src/patchoulene/__init__.py +++ b/patchoulene/src/patchoulene/__init__.py @@ -143,15 +143,16 @@ def do_diff_commits( if p not in db: break - merged_bases = [ - m for m in db[p].get("merged", []) if base_is_contained_in(m, base2) - ] - if merged_bases: - merged.add((p, merged_bases[0])) - continue - if db[p].get("replacement", None) is None: - break + # Only consider merged if no replacements + merged_bases = [ + m for m in db[p].get("merged", []) if base_is_contained_in(m, base2) + ] + if merged_bases: + merged.add((p, merged_bases[0])) + continue + else: + break elif isinstance(db[p]["replacement"], list): remaining.update(db[p]["replacement"]) else: