pq-rpm: create diff up to the last merge commit
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 21 Nov 2013 15:25:37 +0000 (17:25 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:47 +0000 (10:07 +0200)
Before, merge commits broke patch generation, or, (most probably) caused
the generated patches to be unapplicable (similar to how
git-format-patch behaves).

Now, changes up to the last merge commit are squashed into one diff if
merge commits are found in the revision list from which patches are to
be generated. Individual patches (one per commit) are generated from the
last merge commit up to the exported revision.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/pq_rpm.py

index b9ae740537bcc3c3a0ed9a5a369f5745806e56f4..9572790e1d8a3269646f25cb5f7c7b0f88e4d6e9 100755 (executable)
@@ -118,6 +118,20 @@ def generate_patches(repo, start, squash, end, outdir, options):
             if patch_fn:
                 patches.append(patch_fn)
                 start = squash_sha1
+    # Check for merge commits, yet another squash if merges found
+    merges = repo.get_commits(start, end_commit, options=['--merges'])
+    if merges:
+        # Shorten SHA1s
+        start_sha1 = repo.rev_parse(start, short=7)
+        merge_sha1 = repo.rev_parse(merges[0], short=7)
+        patch_fn = format_diff(outdir, None, repo, start_sha1, merge_sha1,
+                               options.patch_ignore_path)
+        if patch_fn:
+            gbp.log.info("Merge commits found! Diff between %s..%s written "
+                         "into one monolithic diff" % (start_sha1, merge_sha1))
+            patches.append(patch_fn)
+            start = merge_sha1
+            print start
 
     # Check for merge commits, squash if merges found
     merges = repo.get_commits(start, end_commit, options=['--merges'])