summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-02-06 14:12:54 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-02-24 09:09:48 +0200
commitc457eafdfb4ed34faa7f29cd7090350e4e650a34 (patch)
tree4feef3d210f86b42296177a045c0ef3b60819f1d
parent27579ee44f0492e9d3d63d238640a3ba2fe77c96 (diff)
downloadgit-buildpackage-c457eafdfb4ed34faa7f29cd7090350e4e650a34.tar.gz
git-buildpackage-c457eafdfb4ed34faa7f29cd7090350e4e650a34.tar.bz2
git-buildpackage-c457eafdfb4ed34faa7f29cd7090350e4e650a34.zip
pq-rpm: implement '--import-files' command line option
For defining the packaging file(s) that will be imported into the development/patch-queue branch. By default, the local gbp conf files are imported. NOTE: This option does not affect the patch files that are imported. The files defined with this option will appear as one monolithic commit in the development/patch-queue branch. Change-Id: Ia1967d77d2be5a8afc41e8d32c84b3386bc45924 Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/config.py7
-rwxr-xr-xgbp/scripts/pq_rpm.py29
-rw-r--r--tests/component/rpm/test_pq_rpm.py25
3 files changed, 47 insertions, 14 deletions
diff --git a/gbp/config.py b/gbp/config.py
index ea5b505f..c3f756ea 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -542,6 +542,8 @@ class GbpOptionParserRpm(GbpOptionParser):
'packaging-tag' : '%(vendor)s/%(version)s',
'upstream-tag' : 'upstream/%(upstreamversion)s',
'pq-branch' : 'development/%(branch)s',
+ 'import-files' : ['.gbp.conf',
+ 'debian/gbp.conf'],
'spec-file' : 'auto',
'export-dir' : '../rpmbuild',
'ignore-untracked' : 'False',
@@ -574,6 +576,11 @@ class GbpOptionParserRpm(GbpOptionParser):
"format string for packaging tags, rpm counterpart of the 'debian-tag' option, default is '%(packaging-tag)s'",
'pq-branch':
"format string for the patch-queue branch name, default is '%(pq-branch)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"),
'spec-file':
"Spec file to use, 'auto' makes gbp to guess, other values make the packaging-dir option to be ignored, default is '%(spec-file)s'",
'ignore-untracked':
diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py
index 261cea19..07c1e480 100755
--- a/gbp/scripts/pq_rpm.py
+++ b/gbp/scripts/pq_rpm.py
@@ -315,17 +315,17 @@ def get_packager(spec):
return GitModifier(match.group('name'), match.group('email'))
return GitModifier()
-def import_gbp_conf(repo, commitish):
+def import_extra_files(repo, commitish, files):
"""Import branch-specific gbp.conf files to current branch"""
- files = ['.gbp.conf', 'debian/gbp.conf']
found = {}
for fname in files:
- try:
- found[fname] = repo.show('%s:%s' % (commitish, fname))
- except GitRepositoryError:
- pass
+ if fname:
+ try:
+ found[fname] = repo.show('%s:%s' % (commitish, fname))
+ except GitRepositoryError:
+ pass
if found:
- gbp.log.info('Importing gbp.conf file(s) from %s into %s' %
+ gbp.log.info('Importing additional file(s) from %s into %s' %
(commitish, repo.get_branch()))
for fname, content in found.iteritems():
dirname = os.path.dirname(fname)
@@ -337,8 +337,9 @@ def import_gbp_conf(repo, commitish):
files = found.keys()
gbp.log.debug('Adding/commiting %s' % files)
repo.add_files(files, force=True)
- commit_msg = 'Auto-import gbp.conf file(s) from %s\n\n' \
- 'Gbp: Ignore\nGbp-Rpm: Ignore' % commitish
+ commit_msg = ('Auto-import packaging file(s) from branch %s:\n'
+ ' %s\n\nGbp: Ignore\nGbp-Rpm: Ignore' % (commitish,
+ ' '.join(files)))
repo.commit_files(files, msg=commit_msg)
def import_spec_patches(repo, options):
@@ -394,7 +395,7 @@ def import_spec_patches(repo, options):
try:
gbp.log.info("Switching to %s" % pq_branch)
repo.set_branch(pq_branch)
- import_gbp_conf(repo, base)
+ import_extra_files(repo, base, options.import_files)
gbp.log.info("Trying to apply patches from '%s' onto '%s'" %
(base, upstream_commit))
for patch in queue:
@@ -475,6 +476,11 @@ def apply_single_patch(repo, patchfile, options):
apply_and_commit_patch(repo, patch, fallback_author=None)
+def opt_split_cb(option, opt_str, value, parser):
+ """Split option string into a list"""
+ setattr(parser.values, option.dest, value.split(','))
+
+
def main(argv):
"""Main function for the gbp pq-rpm command"""
retval = 0
@@ -512,6 +518,9 @@ def main(argv):
"this is used as the 'base' branch. Default is "
"'%(packaging-branch)s'")
parser.add_config_file_option(option_name="pq-branch", dest="pq_branch")
+ parser.add_config_file_option(option_name="import-files",
+ dest="import_files", type="string", action="callback",
+ callback=opt_split_cb)
parser.add_option("--export-rev", action="store", dest="export_rev",
default="",
help="Export patches from treeish object TREEISH instead of head "
diff --git a/tests/component/rpm/test_pq_rpm.py b/tests/component/rpm/test_pq_rpm.py
index 63d773fa..8356cdd4 100644
--- a/tests/component/rpm/test_pq_rpm.py
+++ b/tests/component/rpm/test_pq_rpm.py
@@ -492,8 +492,8 @@ class TestPqRpm(ComponentTestBase):
branches = ['master', 'upstream', 'development/master']
self._check_repo_state(repo, 'master', branches, files)
- def test_gbp_conf_import(self):
- """Test importing of gbp.conf files into pq branch"""
+ def test_option_import_files(self):
+ """Test the --import-files cmdline option"""
repo = self.init_test_repo('gbp-test')
# Add new conf file
os.mkdir('debian')
@@ -502,12 +502,29 @@ class TestPqRpm(ComponentTestBase):
repo.add_files(['debian/gbp.conf'], force=True)
repo.commit_files(['debian/gbp.conf'], msg="Add conf file")
- # Import
+ # Import with default settings (should import gbp conf files)
branches = repo.get_local_branches() + ['my-pq-branch']
eq_(mock_pq(['import']), 0)
self._check_repo_state(repo, 'my-pq-branch', branches)
-
ok_('debian/gbp.conf' in repo.list_files())
+ ok_('.gbp.conf' in repo.list_files())
+
+ # Re-import with user-defined files
+ eq_(mock_pq(['import', '--force', '--packaging-branch', 'master',
+ '--import-files', 'foo.txt,my.patch']), 0)
+ self._check_repo_state(repo, 'my-pq-branch', branches)
+ ok_('foo.txt' in repo.list_files())
+ ok_('my.patch' in repo.list_files())
+
+ # Drop and re-import with no files
+ eq_(mock_pq(['switch', '--packaging-branch', 'master', '--pq-branch',
+ 'my-pq-branch']), 0)
+ eq_(mock_pq(['drop']), 0)
+ eq_(mock_pq(['import', '--packaging-branch', 'master',
+ '--pq-branch', 'my-pq-branch', '--import-files=']), 0)
+ self._check_repo_state(repo, 'my-pq-branch', branches)
+ ok_('debian/gbp.conf' not in repo.list_files())
+ ok_('.gbp.conf' not in repo.list_files())
def test_import_unapplicable_patch(self):
"""Test import when a patch does not apply"""