From 4253d6d5f0427a05d844517fbed81030b4a13fb8 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 18 May 2022 12:22:31 -0700 Subject: [PATCH] [upstream_utils] Apply "git am" patches individually (#4250) Also, giving am_patches() zero patches isn't an error. The function will just be a no-op. --- upstream_utils/upstream_utils.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/upstream_utils/upstream_utils.py b/upstream_utils/upstream_utils.py index d52b3b2f01..f3460e9976 100644 --- a/upstream_utils/upstream_utils.py +++ b/upstream_utils/upstream_utils.py @@ -192,7 +192,8 @@ def comment_out_invalid_includes(filename, include_roots): def apply_patches(root, patches): - """Apply list of patches to the destination Git repository. + """Apply list of patches to the destination Git repository using "git + apply". Keyword arguments: root -- the root directory of the destination Git repository @@ -204,21 +205,16 @@ def apply_patches(root, patches): def am_patches(root, patches, use_threeway=False): - """Apply list of patches to the destination Git repository. + """Apply list of patches to the destination Git repository using "git am". Keyword arguments: root -- the root directory of the destination Git repository patches -- list of patch files relative to the root """ - if len(patches) == 0: - raise Exception("Must provide at least one patch") - os.chdir(root) args = ["git", "am"] if use_threeway: args.append("-3") for patch in patches: - args.append(patch) - - subprocess.check_output(args) + subprocess.check_output(args + [patch])