aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/git.py
diff options
context:
space:
mode:
authorJian Cai <jiancai@google.com>2020-04-30 15:29:03 -0700
committerJian Cai <jiancai@google.com>2020-05-02 01:39:31 +0000
commitfbefdc4647a046010844aa2ea2551f15c80ef3aa (patch)
treec3c76d09467db931c37688489f1e7076db0685a3 /llvm_tools/git.py
parent22416832569728600cab98c5bd282c698ef21a7c (diff)
downloadtoolchain-utils-fbefdc4647a046010844aa2ea2551f15c80ef3aa.tar.gz
llvm_tool: cherry-pick multiple patches at once
This change will allow cherrypick_cl.py to take in multiple SHAs at once and create local patches accordingly. All these SHAs will be applied to the same starting SHA. The package a patch applies to will be inferred automatically, so users no longer have to specify the package name. If a patch changes files in more than one package, it will be split into smaller patches by package and applied accordingly. The patch information will be added to PATCHES.json of each affected package. BUG=chromium:1057428 TEST=local tests. Change-Id: I8c4d93716b7682b42c8202e8b939ca2175775fdf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2175675 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: Jian Cai <jiancai@google.com>
Diffstat (limited to 'llvm_tools/git.py')
-rwxr-xr-xllvm_tools/git.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/llvm_tools/git.py b/llvm_tools/git.py
index 778d9695..f38d5e72 100755
--- a/llvm_tools/git.py
+++ b/llvm_tools/git.py
@@ -46,10 +46,9 @@ def CreateBranch(repo, branch):
if not os.path.isdir(repo):
raise ValueError('Invalid directory path provided: %s' % repo)
- subprocess.check_output(['git', '-C', repo, 'reset', 'HEAD', '--hard'],
- encoding='utf-8')
+ subprocess.check_output(['git', '-C', repo, 'reset', 'HEAD', '--hard'])
- subprocess.check_output(['repo', 'start', branch], cwd=repo, encoding='utf-8')
+ subprocess.check_output(['repo', 'start', branch], cwd=repo)
def DeleteBranch(repo, branch):
@@ -66,14 +65,11 @@ def DeleteBranch(repo, branch):
if not os.path.isdir(repo):
raise ValueError('Invalid directory path provided: %s' % repo)
- subprocess.check_output(['git', '-C', repo, 'checkout', 'cros/master'],
- encoding='utf-8')
+ subprocess.check_output(['git', '-C', repo, 'checkout', 'cros/master'])
- subprocess.check_output(['git', '-C', repo, 'reset', 'HEAD', '--hard'],
- encoding='utf-8')
+ subprocess.check_output(['git', '-C', repo, 'reset', 'HEAD', '--hard'])
- subprocess.check_output(['git', '-C', repo, 'branch', '-D', branch],
- encoding='utf-8')
+ subprocess.check_output(['git', '-C', repo, 'branch', '-D', branch])
def UploadChanges(repo, branch, commit_messages):
@@ -102,28 +98,17 @@ def UploadChanges(repo, branch, commit_messages):
f.write('\n'.join(commit_messages))
f.flush()
- subprocess.check_output(['git', 'commit', '-F', f.name],
- cwd=repo,
- encoding='utf-8')
+ subprocess.check_output(['git', 'commit', '-F', f.name], cwd=repo)
# Upload the changes for review.
- # Pylint currently doesn't lint things in py3 mode, and py2 didn't allow
- # users to specify `encoding`s for Popen. Hence, pylint is "wrong" here.
- # pylint: disable=unexpected-keyword-arg
- # The CL URL is sent to 'stderr', so need to redirect 'stderr' to 'stdout'.
- upload_changes_obj = subprocess.Popen(
+ out = subprocess.check_output(
['repo', 'upload', '--yes', '--ne', '--no-verify',
'--br=%s' % branch],
- cwd=repo,
- stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
+ cwd=repo,
encoding='utf-8')
- out, _ = upload_changes_obj.communicate()
-
- if upload_changes_obj.returncode: # Failed to upload changes.
- print(out)
- raise ValueError('Failed to upload changes for review')
+ print(out)
found_url = re.search(
r'https://chromium-review.googlesource.com/c/'