llvm.org GIT mirror llvm / 8524467
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 Mehdi Amini 2 years ago
1 changed file(s) with 13 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
8181 d = head
8282
8383
84 def shell(cmd, strip=True, cwd=None, stdin=None):
84 def shell(cmd, strip=True, cwd=None, stdin=None, die_on_failure=True):
8585 log_verbose('Running: %s' % ' '.join(cmd))
8686
8787 start = time.time()
9999 if strip:
100100 stdout = stdout.rstrip('\r\n')
101101 return stdout
102 eprint('`%s` returned %s' % (' '.join(cmd), p.returncode))
102 err_msg = '`%s` returned %s' % (' '.join(cmd), p.returncode)
103 eprint(err_msg)
103104 if stderr:
104105 eprint(stderr.rstrip())
105 sys.exit(2)
106 if die_on_failure:
107 sys.exit(2)
108 raise RuntimeError(err_msg)
106109
107110
108111 def git(*cmd, **kwargs):
186189 svn_sr_path = os.path.join(svn_repo, GIT_TO_SVN_DIR[sr])
187190 # git is the only thing that can handle its own patches...
188191 log_verbose('Apply patch: %s' % diff)
189 shell(['git', 'apply', '-p2', '-'], cwd=svn_sr_path, stdin=diff)
192 try:
193 shell(['git', 'apply', '-p2', '-'], cwd=svn_sr_path, stdin=diff,
194 die_on_failure=False)
195 except RuntimeError as e:
196 eprint("Patch doesn't apply: maybe you should try `git pull -r` "
197 "first?")
198 sys.exit(2)
190199
191200 status_lines = svn(svn_repo, 'status').split('\n')
192201