aboutsummaryrefslogtreecommitdiff
path: root/gbp/scripts/import_dsc.py
diff options
context:
space:
mode:
authorGuido G√ľnther <agx@sigxcpu.org>2013-11-06 17:39:24 +0100
committerGuido G√ľnther <agx@sigxcpu.org>2013-11-06 18:56:42 +0100
commitab5a7086cd55f0a924ee7644a42eeab159753151 (patch)
tree74eb7a785c702afc62f81a8dc3b2aad3c8ff0259 /gbp/scripts/import_dsc.py
parentce5c0a9273a18b14368bf39e74c893e70b34b0a3 (diff)
import-dsc; Merge upstream version by tag
instead of simply using the upstream branch name. THis makes sure we also merge upstream versions that were imported previously with e.g. "gbp import-orig". Closes: #698222
Diffstat (limited to 'gbp/scripts/import_dsc.py')
-rw-r--r--gbp/scripts/import_dsc.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index 1744362..2da4aac 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -111,7 +111,27 @@ def get_committer_from_author(author, options):
return committer
-def apply_debian_patch(repo, unpack_dir, src, options, parents):
+def check_parents(repo, branch, tag):
+ """
+ Check if the upstream tag is already merged, if not, return
+ the additional parent to merge
+ """
+ parents = None
+ rev = None
+
+ try:
+ rev = repo.rev_parse("%s^{commit}" % tag)
+ except GitRepositoryError:
+ pass
+
+ if rev and not repo.branch_contains(branch, rev):
+ gbp.log.debug("Tag '%s' not yet merged into '%s'"
+ % (tag, branch))
+ parents = [rev]
+
+ return parents
+
+def apply_debian_patch(repo, unpack_dir, src, options, tag):
"""apply the debian patch and tag appropriately"""
try:
os.chdir(unpack_dir)
@@ -126,6 +146,10 @@ def apply_debian_patch(repo, unpack_dir, src, options, parents):
os.chmod('debian/rules', 0755)
os.chdir(repo.path)
+ parents = check_parents(repo,
+ options.debian_branch,
+ tag)
+
author = get_author_from_changelog(unpack_dir)
committer = get_committer_from_author(author, options)
commit = repo.commit_dir(unpack_dir,
@@ -351,12 +375,12 @@ def main(argv):
repo.create_branch(options.upstream_branch, commit)
if options.pristine_tar:
repo.pristine_tar.commit(src.tgz, options.upstream_branch)
- parents = [ options.upstream_branch ]
if is_empty and not repo.has_branch(options.debian_branch):
repo.create_branch(options.debian_branch, commit)
if not src.native:
if src.diff or src.deb_tgz:
- apply_debian_patch(repo, upstream.unpacked, src, options, parents)
+ apply_debian_patch(repo, upstream.unpacked, src, options,
+ tag)
else:
gbp.log.warn("Didn't find a diff to apply.")
if repo.get_branch() == options.debian_branch or is_empty: