From 91fbdc17c8f529f649db7521f85a39e99d0cc4a4 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 3 May 2013 11:04:28 +0300 Subject: [PATCH] pq: support patch-export commands Support giving commands to pq as a meta tag in commit message. The format is "Gbp: [args]". Currently, only one command is supported. namely 'ignore'. That is, one can use 'Gbp: Ignore' in the commit message for ignoring the commit in patch-generation. Signed-off-by: Markus Lehtonen --- gbp/scripts/common/pq.py | 23 +++++++++++++++++++++++ gbp/scripts/pq.py | 13 +++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index 050e7df..b6b2118 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -68,6 +68,29 @@ def pq_branch_base(pq_branch): return pq_branch[len(PQ_BRANCH_PREFIX):] +def parse_gbp_commands(info, cmd_tag, noarg_cmds, arg_cmds): + """Parse gbp commands from commit message""" + cmd_re = re.compile(r'^%s:\s*(?P[a-z-]+)(\s+(?P\S.*))?' % + cmd_tag, flags=re.I) + commands = {} + for line in info['body'].splitlines(): + match = re.match(cmd_re, line) + if match: + cmd = match.group('cmd').lower() + if arg_cmds and cmd in arg_cmds: + if match.group('args'): + commands[cmd] = match.group('args') + else: + gbp.log.warn("Ignoring gbp-command '%s' in commit %s: " + "missing cmd arguments" % (line, info['id'])) + elif noarg_cmds and cmd in noarg_cmds: + commands[cmd] = match.group('args') + else: + gbp.log.warn("Ignoring unknow gbp-command '%s' in commit %s" + % (line, info['id'])) + return commands + + def patch_path_filter(file_status, exclude_regex=None): """ Create patch include paths, i.e. a "negation" of the exclude paths. diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index c0f0946..f5618ce 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -30,8 +30,9 @@ from gbp.errors import GbpError import gbp.log from gbp.patch_series import (PatchSeries, Patch) from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base, - format_patch, switch_to_pq_branch, - apply_single_patch, apply_and_commit_patch, + parse_gbp_commands, format_patch, + switch_to_pq_branch, apply_single_patch, + apply_and_commit_patch, drop_pq, get_maintainer_from_control) PATCH_DIR = "debian/patches/" @@ -53,8 +54,12 @@ def generate_patches(repo, start, end, outdir, options): topic_regex = 'gbp-pq-topic:\s*(?P\S.*)' for commit in rev_list: info = repo.get_commit_info(commit) - format_patch(outdir, repo, info, patches, options.patch_numbers, - topic_regex=topic_regex) + cmds = parse_gbp_commands(info, 'gbp', ('ignore'), None) + if not 'ignore' in cmds: + format_patch(outdir, repo, info, patches, options.patch_numbers, + topic_regex=topic_regex) + else: + gbp.log.info('Ignoring commit %s' % info['id']) return patches -- 2.7.4