[llvm] r286695 - Improve `git llvm push` to suggest `git pull` when applying patch fails
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 17:17:59 PST 2016
Author: mehdi_amini
Date: Fri Nov 11 19:17:59 2016
New Revision: 286695
URL: http://llvm.org/viewvc/llvm-project?rev=286695&view=rev
Log:
Improve `git llvm push` to suggest `git pull` when applying patch fails
Differential Revision: https://reviews.llvm.org/D26565
Modified:
llvm/trunk/utils/git-svn/git-llvm
Modified: llvm/trunk/utils/git-svn/git-llvm
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/git-svn/git-llvm?rev=286695&r1=286694&r2=286695&view=diff
==============================================================================
--- llvm/trunk/utils/git-svn/git-llvm (original)
+++ llvm/trunk/utils/git-svn/git-llvm Fri Nov 11 19:17:59 2016
@@ -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, std
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_
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')
More information about the llvm-commits
mailing list