diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-12-10 15:25:32 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-12-16 09:55:14 +0200 |
commit | 16d8ac4d7a78f9a62eecae6f8dc521201a0678fc (patch) | |
tree | 74820657a6dd1cee8809beea9917a3749d0fc3c1 /gbp | |
parent | 13a3087d5afcfcee308595b2c224ffe5cdc12c94 (diff) |
pq-rpm: implement '--import-files' command line option
The new option can be used to "copy" files from the packaging branch to
the patch-queue branch when doing pq import. The files defined with this
option will appear as new files in one monolithic commit in the
development/patch-queue branch.
By default, the local gbp conf files are imported in order to try to
ensure that gbp sees the same settings on the patch-queue branch as
on the packaging branch.
NOTE: This option does not affect the importing (i.e. apply and commit)
of patches.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/config.py | 11 | ||||
-rwxr-xr-x | gbp/scripts/pq_rpm.py | 34 |
2 files changed, 42 insertions, 3 deletions
diff --git a/gbp/config.py b/gbp/config.py index 47ef19e..e508b0b 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -46,6 +46,11 @@ def check_tristate(option, opt, value): return val +def optparse_split_cb(option, opt_str, value, parser): + """Split option string into a list""" + setattr(parser.values, option.dest, value.split(',')) + + def safe_option(f): def _decorator(self, *args, **kwargs): obj = self @@ -542,6 +547,8 @@ class GbpOptionParserRpm(GbpOptionParser): 'packaging-dir' : '', 'packaging-tag' : 'packaging/%(version)s', 'spec-file' : '', + 'import-files' : ['.gbp.conf', + 'debian/gbp.conf'], }) help = dict(GbpOptionParser.help) @@ -564,6 +571,10 @@ class GbpOptionParserRpm(GbpOptionParser): 'spec-file': "Spec file to use, causes the packaging-dir option to be " "ignored, default is '%(spec-file)s'", + 'import-files': + "Comma-separated list of additional file(s) to import from " + "packaging branch. These will appear as one monolithic patch " + "in the pq/development branch. Default is %(import-files)s", }) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index 3d1c4bc..5166b5c 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -29,7 +29,7 @@ import sys import gbp.log import gbp.tmpfile as tempfile -from gbp.config import GbpOptionParserRpm +from gbp.config import GbpOptionParserRpm, optparse_split_cb from gbp.rpm.git import GitRepositoryError, RpmGitRepository from gbp.git.modifier import GitModifier from gbp.command_wrappers import GitCommand, CommandExecFailed @@ -96,8 +96,9 @@ def generate_patches(repo, start, end, outdir, options): # Generate patches for commit in reversed(repo.get_commits(start, end_commit)): info = repo.get_commit_info(commit) - cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), - ('if', 'ifarch')) + cmds = parse_gbp_commands(info, 'gbp', ('ignore'), ('topic')) + cmds.update(parse_gbp_commands(info, 'gbp-pq-rpm', ('ignore'), + ('if', 'ifarch'))) if not 'ignore' in cmds: patch_fn = format_patch(outdir, repo, info, patches, options.patch_numbers) @@ -259,6 +260,28 @@ def get_packager(spec): return GitModifier() +def import_extra_files(repo, commitish, files, patch_ignore=True): + """Import branch-specific gbp.conf files to current branch""" + for path in files: + if path: + try: + repo.checkout_files(commitish, path) + except GitRepositoryError: + pass + repo_status = repo.status() + added = repo_status['A '] if 'A ' in repo_status else [] + if added: + gbp.log.info("Importing additional file(s) from branch '%s' into '%s'" % + (commitish, repo.get_branch())) + gbp.log.debug('Adding/commiting %s' % added) + commit_msg = ("Auto-import file(s) from branch '%s':\n %s\n" % + (commitish, ' '.join(added))) + if patch_ignore: + commit_msg += "\nGbp: Ignore" + repo.commit_files(added, msg=commit_msg) + return added + + def import_spec_patches(repo, options): """ apply a series of patches in a spec/packaging dir to branch @@ -311,6 +334,7 @@ def import_spec_patches(repo, options): try: gbp.log.info("Switching to branch '%s'" % pq_branch) repo.set_branch(pq_branch) + import_extra_files(repo, base, options.import_files) if not queue: return @@ -382,6 +406,10 @@ switch Switch to patch-queue branch and vice versa.""") parser.add_config_file_option(option_name="spec-file", dest="spec_file") parser.add_config_file_option(option_name="packaging-dir", dest="packaging_dir") + parser.add_config_file_option(option_name="import-files", + dest="import_files", type="string", action="callback", + callback=optparse_split_cb) + return parser |