aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/common/pq.py
diff options
context:
space:
mode:
Diffstat (limited to 'gbp/scripts/common/pq.py')
-rw-r--r--gbp/scripts/common/pq.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
index 5580426b..fca4ec31 100644
--- a/gbp/scripts/common/pq.py
+++ b/gbp/scripts/common/pq.py
@@ -176,6 +176,7 @@ def write_patch_file(filename, commit_info, diff):
DEFAULT_PATCH_NUM_PREFIX_FORMAT = "%04d-"
+
def format_patch(outdir, repo, commit_info, series, numbered=True,
path_exclude_regex=None, topic='', name=None, renumber=False,
patch_num_prefix_format=DEFAULT_PATCH_NUM_PREFIX_FORMAT):
@@ -188,10 +189,10 @@ def format_patch(outdir, repo, commit_info, series, numbered=True,
try:
num_prefix = str(patch_num_prefix_format) % (len(series) + 1) \
- if numbered else ''
+ if numbered else ''
except Exception:
- gbp.log.warn("Bad format format string '%s', " \
- "falling back to default '%s'" % \
+ gbp.log.warn("Bad format format string '%s', "
+ "falling back to default '%s'" %
(str(patch_num_prefix_format),
DEFAULT_PATCH_NUM_PREFIX_FORMAT))
num_prefix = DEFAULT_PATCH_NUM_PREFIX_FORMAT % (len(series) + 1)
@@ -200,7 +201,7 @@ def format_patch(outdir, repo, commit_info, series, numbered=True,
if renumber:
# Remove any existing numeric prefix if the patch
# should be renumbered
- name = re.sub('^\d+[-_]*', '', name)
+ name = re.sub('^\d+[-_]*', '', name)
else:
# Otherwise, clear proposed prefix
num_prefix = ''
@@ -214,9 +215,8 @@ def format_patch(outdir, repo, commit_info, series, numbered=True,
filepath = os.path.join(outdir, filename)
# Make sure that we don't overwrite existing patches in the series
if filepath in series:
- presuffix = '-%d' % \
- len([p for p in series \
- if p.startswith(os.path.splitext(filepath)[0])])
+ presuffix = '-%d' % len([p for p in series
+ if p.startswith(os.path.splitext(filepath)[0])])
filename = num_prefix + base + presuffix + suffix
filepath = os.path.join(outdir, filename)
@@ -316,7 +316,11 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None, name=None):
else:
gbp.log.warn("Patch '%s' has no authorship information" % patch_fn)
- repo.apply_patch(patch.path, strip=patch.strip)
+ try:
+ repo.apply_patch(patch.path, strip=patch.strip)
+ except GitRepositoryError:
+ gbp.log.warn("Patch %s failed to apply, retrying with whitespace fixup" % patch_fn)
+ repo.apply_patch(patch.path, strip=patch.strip, fix_ws=True)
tree = repo.write_tree()
msg = "%s\n\n%s" % (patch.subject, patch.long_desc)
if topic: