llvm_tools: Print removed in patch_manager.py
We should print out what we actually did, instead of just
exiting silently when everything goes well. This is
informative to the user running patch_manager.py code.
BUG=b:188465085
TEST=./patch_manager_unittest.py
Change-Id: Idcb203d0c3e28d1b00e7b9503334863b7844d033
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3706059
Reviewed-by: George Burgess <gbiv@chromium.org>
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
diff --git a/llvm_tools/patch_manager.py b/llvm_tools/patch_manager.py
index b499d52..eba3a53 100755
--- a/llvm_tools/patch_manager.py
+++ b/llvm_tools/patch_manager.py
@@ -481,12 +481,15 @@
patches_list = json.load(f)
patch_entries = (patch_utils.PatchEntry.from_dict(llvm_src_dir, elem)
for elem in patches_list)
- filtered_entries = [
- entry.to_dict() for entry in patch_entries
- if not entry.is_old(svn_version)
- ]
+ oldness = [(entry, entry.is_old(svn_version)) for entry in patch_entries]
+ filtered_entries = [entry.to_dict() for entry, old in oldness if not old]
with patch_utils.atomic_write(patches_json_fp, encoding='utf-8') as f:
_WriteJsonChanges(filtered_entries, f)
+ removed_entries = [entry for entry, old in oldness if old]
+ plural_patches = 'patch' if len(removed_entries) == 1 else 'patches'
+ print(f'Removed {len(removed_entries)} old {plural_patches}:')
+ for r in removed_entries:
+ print(f'- {r.rel_patch_path}: {r.title()}')
def UpdateVersionRanges(svn_version: int, llvm_src_dir: Path,