summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-05-08 20:42:45 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-05 14:20:05 +0300
commit8aaf27ee955584f40a022af9dc4dd5a1b3aecfed (patch)
treeaa2003177d58a9032b6172ebbf6480b4a9953568
parent55c42219e10be5cc08cf0f35e770a45a3bff4d09 (diff)
downloadgit-buildpackage-8aaf27ee955584f40a022af9dc4dd5a1b3aecfed.tar.gz
git-buildpackage-8aaf27ee955584f40a022af9dc4dd5a1b3aecfed.tar.bz2
git-buildpackage-8aaf27ee955584f40a022af9dc4dd5a1b3aecfed.zip
pq-rpm: support patch-export up to an arbitrary tree-ish
If the end of the export range is not a commit "normal" patches are generated up to HEAD and finally a raw diff between HEAD and the end-tree-is generated. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rwxr-xr-xgbp/scripts/pq_rpm.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py
index 267357be..1e3c44a9 100755
--- a/gbp/scripts/pq_rpm.py
+++ b/gbp/scripts/pq_rpm.py
@@ -36,6 +36,7 @@ from gbp.patch_series import (PatchSeries, Patch)
from gbp.rpm import (SpecFile, guess_spec)
from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base,
parse_gbp_commands, format_patch,
+ format_diff,
switch_to_pq_branch, apply_single_patch,
apply_and_commit_patch, drop_pq)
@@ -51,8 +52,21 @@ def generate_patches(repo, start, end, outdir, options):
if not repo.has_treeish(treeish):
raise GbpError('%s not a valid tree-ish' % treeish)
+ try:
+ end_commit = end
+ end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+ except GitRepositoryError:
+ # In case of plain tree-ish objects, assume current branch head is the
+ # last commit
+ end_commit = "HEAD"
+ end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+
+ start_sha1 = repo.rev_parse("%s^0" % start)
+ if repo.get_merge_base(start_sha1, end_commit_sha1) != start_sha1:
+ raise GbpError("Start commit '%s' not an ancestor of end commit "
+ "'%s'" % (start, end_commit))
# Generate patches
- for commit in reversed(repo.get_commits(start, end)):
+ for commit in reversed(repo.get_commits(start, end_commit)):
info = repo.get_commit_info(commit)
cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), None)[0]
if not 'ignore' in cmds:
@@ -63,6 +77,13 @@ def generate_patches(repo, start, end, outdir, options):
else:
gbp.log.info('Ignoring commit %s' % info['id'])
+ # Generate diff to the tree-ish object
+ if end_commit != end:
+ gbp.log.info("Generating diff file %s..%s" % (end_commit, end))
+ patch_fn = format_diff(outdir, None, repo, end_commit, end)
+ if patch_fn:
+ patches.append(patch_fn)
+
return patches, commands