aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan R Abrahams-Whitehead <ajordanr@google.com>2022-10-14 23:10:09 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 23:51:37 +0000
commitbe528176c1b17e5e296922eefd80c34506d3312c (patch)
tree2eaee1c421893448d839d05e2dd9c93e7ce789b7
parentb20b2304b692de6a423acb0035303d53c4ee3e3d (diff)
downloadtoolchain-utils-be528176c1b17e5e296922eefd80c34506d3312c.tar.gz
llvm_tools: Fix patch_utils patch writing
There were two bugs with patch_utils here: 1. When deciding to modify patches, it didn't ignore old patches. 2. When writing out changes, it wrote the dicts out in the wrong order. Both of these issues have been resolved. BUG=b:253660089 TEST=./patch_utils_unittest.py TEST=./patch_manager_unittest.py TEST=./update_chromeos_llvm_hash_unittest.py TEST=./update_chromeos_llvm_hash.py TEST=./update_chromeos_llvm_hash.py \ --is_llvm_next \ --llvm_version tot \ --failure_mode disable_patches Change-Id: If25c30ffa2bea55aeafb8d03aa19c5fc07fb4b7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3956311 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
-rw-r--r--llvm_tools/patch_utils.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm_tools/patch_utils.py b/llvm_tools/patch_utils.py
index b86e1925..affb3d0d 100644
--- a/llvm_tools/patch_utils.py
+++ b/llvm_tools/patch_utils.py
@@ -197,15 +197,19 @@ class PatchEntry:
)
def to_dict(self) -> Dict[str, Any]:
- out = {
+ out: Dict[str, Any] = {
"metadata": self.metadata,
- "rel_patch_path": self.rel_patch_path,
- "version_range": self.version_range,
}
if self.platforms:
# To match patch_sync, only serialized when
# non-empty and non-null.
out["platforms"] = sorted(self.platforms)
+ out.update(
+ {
+ "rel_patch_path": self.rel_patch_path,
+ "version_range": self.version_range,
+ }
+ )
return out
def parsed_hunks(self) -> Dict[str, List[Hunk]]:
@@ -500,11 +504,11 @@ def update_version_ranges(
)
return PatchInfo(
non_applicable_patches=[],
- applied_patches=[p.rel_patch_path for p in applied_patches],
+ applied_patches=applied_patches,
failed_patches=[],
disabled_patches=[p.rel_patch_path for p in modified_entries],
removed_patches=[],
- modified_metadata=patches_json_fp if modified_entries else None,
+ modified_metadata=str(patches_json_fp) if modified_entries else None,
)
@@ -528,8 +532,9 @@ def update_version_ranges_with_entries(
"""
modified_entries: List[PatchEntry] = []
applied_patches: List[PatchEntry] = []
+ active_patches = (pe for pe in patch_entries if not pe.is_old(svn_version))
with git_clean_context(llvm_src_dir):
- for pe in patch_entries:
+ for pe in active_patches:
test_result = pe.test_apply(llvm_src_dir)
if not test_result:
if pe.version_range is None:
@@ -579,14 +584,11 @@ def remove_old_patches(
for r in removed_entries:
print(f"- {r.rel_patch_path}: {r.title()}")
- patches_dir_path = llvm_src_dir / patches_json_fp.parent
return PatchInfo(
non_applicable_patches=[],
applied_patches=[],
failed_patches=[],
disabled_patches=[],
- removed_patches=[
- patches_dir_path / p.rel_patch_path for p in removed_entries
- ],
- modified_metadata=patches_json_fp if removed_entries else None,
+ removed_patches=[p.rel_patch_path for p in removed_entries],
+ modified_metadata=str(patches_json_fp) if removed_entries else None,
)