|
|
|
@ -77,24 +77,21 @@ def align_stdout(stdout):
|
|
|
|
|
|
|
|
|
|
|
|
class PatchApplicationFailed(Exception):
|
|
|
|
class PatchApplicationFailed(Exception):
|
|
|
|
"""Patch failed to be applied."""
|
|
|
|
"""Patch failed to be applied."""
|
|
|
|
def __init__(self, p, status):
|
|
|
|
def __init__(self, errors, verbose):
|
|
|
|
super(PatchApplicationFailed, self).__init__(p, status)
|
|
|
|
super(PatchApplicationFailed, self).__init__(errors, verbose)
|
|
|
|
self.patch = p
|
|
|
|
self.errors = errors
|
|
|
|
self.status = status
|
|
|
|
self.verbose = verbose
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def filename(self):
|
|
|
|
|
|
|
|
if self.patch:
|
|
|
|
|
|
|
|
return self.patch.filename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
def __str__(self):
|
|
|
|
out = []
|
|
|
|
out = []
|
|
|
|
if self.filename:
|
|
|
|
for e in self.errors:
|
|
|
|
out.append('Failed to apply patch for %s:' % self.filename)
|
|
|
|
p, status = e
|
|
|
|
if self.status:
|
|
|
|
if p and p.filename:
|
|
|
|
out.append(self.status)
|
|
|
|
out.append('Failed to apply patch for %s:' % p.filename)
|
|
|
|
if self.patch:
|
|
|
|
if status:
|
|
|
|
out.append('Patch: %s' % self.patch.dump())
|
|
|
|
out.append(status)
|
|
|
|
|
|
|
|
if p and self.verbose:
|
|
|
|
|
|
|
|
out.append('Patch: %s' % p.dump())
|
|
|
|
return '\n'.join(out)
|
|
|
|
return '\n'.join(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -251,6 +248,7 @@ class GitCheckout(CheckoutBase):
|
|
|
|
['checkout', '-b', self.working_branch, '-t', self.remote_branch,
|
|
|
|
['checkout', '-b', self.working_branch, '-t', self.remote_branch,
|
|
|
|
'--quiet'])
|
|
|
|
'--quiet'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors = []
|
|
|
|
for index, p in enumerate(patches):
|
|
|
|
for index, p in enumerate(patches):
|
|
|
|
stdout = []
|
|
|
|
stdout = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
@ -293,14 +291,15 @@ class GitCheckout(CheckoutBase):
|
|
|
|
print p.filename
|
|
|
|
print p.filename
|
|
|
|
print align_stdout(stdout)
|
|
|
|
print align_stdout(stdout)
|
|
|
|
except OSError, e:
|
|
|
|
except OSError, e:
|
|
|
|
raise PatchApplicationFailed(p, '%s%s' % (align_stdout(stdout), e))
|
|
|
|
errors.append((p, '%s%s' % (align_stdout(stdout), e)))
|
|
|
|
except subprocess.CalledProcessError, e:
|
|
|
|
except subprocess.CalledProcessError, e:
|
|
|
|
raise PatchApplicationFailed(
|
|
|
|
errors.append((p,
|
|
|
|
p,
|
|
|
|
|
|
|
|
'While running %s;\n%s%s' % (
|
|
|
|
'While running %s;\n%s%s' % (
|
|
|
|
' '.join(e.cmd),
|
|
|
|
' '.join(e.cmd),
|
|
|
|
align_stdout(stdout),
|
|
|
|
align_stdout(stdout),
|
|
|
|
align_stdout([getattr(e, 'stdout', '')])))
|
|
|
|
align_stdout([getattr(e, 'stdout', '')]))))
|
|
|
|
|
|
|
|
if errors:
|
|
|
|
|
|
|
|
raise PatchApplicationFailed(errors, verbose)
|
|
|
|
found_files = self._check_output_git(
|
|
|
|
found_files = self._check_output_git(
|
|
|
|
['diff', '--ignore-submodules',
|
|
|
|
['diff', '--ignore-submodules',
|
|
|
|
'--name-only', '--staged']).splitlines(False)
|
|
|
|
'--name-only', '--staged']).splitlines(False)
|
|
|
|
|