All that is needed to do two-step merge (first merge the upstream branch, then
apply the debian diff) is to do a merge at the right moment in `import_dsc.py`.

The following quick-and-dirty patch adds such a merge.

--- /usr/lib/python3/dist-packages/gbp/scripts/import_dsc.py.orig       
2022-07-10 13:14:48.358945384 +0200
+++ /usr/lib/python3/dist-packages/gbp/scripts/import_dsc.py        2022-07-10 
14:22:25.030125614 +0200
@@ -520,20 +520,23 @@ def main(argv):
                 commit = import_upstream(repo, sources[0], dsc, options)
                 imported = True

             if not repo.has_branch(options.debian_branch):
                 if options.create_missing_branches:
                     repo.create_branch(options.debian_branch, commit)
                 else:
                     raise GbpError("Branch %s does not exist, use 
--create-missing-branches" %
                                    options.debian_branch)

+            tag = os.popen("git tag --list 'upstream/*' --sort=-v:refname | head 
-n1").read().rstrip()
+            os.system(f'git merge {tag} --strategy-option theirs -m "Merge tag 
\'{tag}\'"')
+
             if dsc.diff or dsc.deb_tgz:
                 apply_debian_patch(repo, sources[0], dsc, commit, options)
             else:
                 gbp.log.warn("Didn't find a diff to apply.")

             if imported and options.pristine_tar:
                 repo.create_pristine_tar_commits(commit, sources)
         if repo.get_branch() == options.debian_branch or repo.empty:
             # Update HEAD if we modified the checked out branch
             repo.force_head(options.debian_branch, hard=True)

--
Gioele Barabucci

Reply via email to