summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-11-12 01:17:59 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-11-12 01:17:59 +0000
commit8524467ebdd04b449e21052d7cb66a6376c48ed3 (patch)
tree92ef124abe36ec55e3428a923482ad82442c0773 /utils
parent3978213ab713d16d69a5cc652f50d679695b7f2e (diff)
downloadllvm-8524467ebdd04b449e21052d7cb66a6376c48ed3.tar.gz
Improve `git llvm push` to suggest `git pull` when applying patch fails
Differential Revision: https://reviews.llvm.org/D26565 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rwxr-xr-xutils/git-svn/git-llvm17
1 files changed, 13 insertions, 4 deletions
diff --git a/utils/git-svn/git-llvm b/utils/git-svn/git-llvm
index de7d89dc666e..d545c52cb8f5 100755
--- a/utils/git-svn/git-llvm
+++ b/utils/git-svn/git-llvm
@@ -82,7 +82,7 @@ def first_dirname(d):
d = head
-def shell(cmd, strip=True, cwd=None, stdin=None):
+def shell(cmd, strip=True, cwd=None, stdin=None, die_on_failure=True):
log_verbose('Running: %s' % ' '.join(cmd))
start = time.time()
@@ -100,10 +100,13 @@ def shell(cmd, strip=True, cwd=None, stdin=None):
if strip:
stdout = stdout.rstrip('\r\n')
return stdout
- eprint('`%s` returned %s' % (' '.join(cmd), p.returncode))
+ err_msg = '`%s` returned %s' % (' '.join(cmd), p.returncode)
+ eprint(err_msg)
if stderr:
eprint(stderr.rstrip())
- sys.exit(2)
+ if die_on_failure:
+ sys.exit(2)
+ raise RuntimeError(err_msg)
def git(*cmd, **kwargs):
@@ -187,7 +190,13 @@ def svn_push_one_rev(svn_repo, rev, dry_run):
svn_sr_path = os.path.join(svn_repo, GIT_TO_SVN_DIR[sr])
# git is the only thing that can handle its own patches...
log_verbose('Apply patch: %s' % diff)
- shell(['git', 'apply', '-p2', '-'], cwd=svn_sr_path, stdin=diff)
+ try:
+ shell(['git', 'apply', '-p2', '-'], cwd=svn_sr_path, stdin=diff,
+ die_on_failure=False)
+ except RuntimeError as e:
+ eprint("Patch doesn't apply: maybe you should try `git pull -r` "
+ "first?")
+ sys.exit(2)
status_lines = svn(svn_repo, 'status').split('\n')