From 4c8e1d194e2397c4302d5a3fdade33c008fa8eda Mon Sep 17 00:00:00 2001 From: David Date: Thu, 22 Oct 2026 00:50:01 +0400 Subject: [PATCH] fix(tools): merge only the pull requests that share files or exports with the branch in pr_overlap pr_overlap --branch merged every open pull request against main, although a pull request can only appear in the report when it shares a file or an export with the branch, so on a repository with a thousand open pull requests the check did not finish in an hour. probe lists each pull request's files and exports from git diff base...head, without a merge, and scan_all merges only the ones that overlap the branch; the others get empty sets, which is what they would contribute to the report. --out is unchanged. --- tools/pr_overlap.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/pr_overlap.py b/tools/pr_overlap.py index eadcf79576..1634affa97 100644 --- a/tools/pr_overlap.py +++ b/tools/pr_overlap.py @@ -241,9 +241,31 @@ def scan(pr): pr["removed_exports"] = source_changed_exports(diff, "-") +def probe(pr): + changes = git("diff", "--name-only", "--no-renames", "-z", f"refs/pr/base...{pr['ref']}").split("\0") + files = {path for path in changes if path} + if not any(path.startswith("core/libs/prx/") and path.endswith(".cpp") for path in files): + return files, set() + return files, exports(git("diff", "-U0", "--no-color", f"refs/pr/base...{pr['ref']}", "--", "core/libs/prx/*.cpp")) + + +def related(prs, executor): + mine = prs[0] + scan(mine) + others = {n: pr for n, pr in prs.items() if n} + chosen = {} + for (n, pr), (files, found) in zip(others.items(), executor.map(probe, others.values())): + if files & mine["files"] or found & mine["exports"]: + chosen[n] = pr + else: + pr.update(tree=None, files=set(), added=set(), exports=set()) + return chosen + + def scan_all(prs, jobs): with ThreadPoolExecutor(max_workers=jobs) as executor: - list(executor.map(scan, prs.values())) + pending = related(prs, executor) if 0 in prs else prs + list(executor.map(scan, pending.values())) def hunks(pr, path):