Support squashing patches in patch generation
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 20 Aug 2012 14:23:26 +0000 (17:23 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 13 Sep 2012 06:30:04 +0000 (09:30 +0300)
Add new command line and config file option to squash commits in patch
generation into a one monolithic diff. One usage example could be e.g.
in linux kernel to squash commits between base version and stable branch
head into one .diff.

This patch directly facilitates git-buildpackage and just passes the new
option to it.

Command line option takes preference over the config file.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gitbuildsys/cmd_export.py
gitbuildsys/conf.py
tools/gbs

index 1298c6e..ff7dfe1 100644 (file)
@@ -70,6 +70,13 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, opts,
     msger.debug("Using upstream branch: %s" % upstream_branch)
     msger.debug("Using upstream tag format: '%s'" % upstream_tag)
 
+    # Get patch squashing option
+    if opts.squash_patches_until:
+        squash_patches_until = opts.squash_patches_until
+    else:
+        squash_patches_until = configmgr.get('squash_patches_until', 'general')
+
+    # Now, start constructing the argument list
     args = ["argv[0] placeholder", "--git-export-only",
             "--git-ignore-new", "--git-builder=osc",
             "--git-upstream-branch=upstream",
@@ -86,7 +93,9 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, opts,
     else:
         args.extend(["--git-patch-export",
                      "--git-patch-export-compress=100k",
-                     "--git-force-create",])
+                     "--git-force-create",
+                     "--git-patch-export-squash-until=%s" %
+                            squash_patches_until])
         if repo.has_branch("pristine-tar"):
             args.extend(["--git-pristine-tar"])
 
index 0844853..dd2a649 100644 (file)
@@ -185,6 +185,7 @@ class ConfigMgr(object):
                 'editor': '',
                 'upstream_branch': 'upstream',
                 'upstream_tag': 'upstream/%(upstreamversion)s',
+                'squash_patches_until': '',
             },
             'remotebuild': {
                 'build_server': 'https://api.tizen.org',
index 1073b10..f4da7e3 100755 (executable)
--- a/tools/gbs
+++ b/tools/gbs
@@ -160,6 +160,13 @@ class Gbs(cmdln.Cmdln):
                   default=None,
                   dest='upstream_tag',
                   help="Upstream tag format, e.g. 'v%(upstreamversion)s'")
+    @cmdln.option('--squash-patches-until',
+                  default=None,
+                  dest='squash_patches_until',
+                  help="When generating patches, squash patches up to given "\
+                       "commit-ish into one monolithic diff file. Format is "\
+                       "the commit-ish optionally followed by a colon and "\
+                       "diff filename base.")
     def do_export(self, _subcmd, opts, *args):
         """${cmd_name}: export files and prepare for build
 
@@ -391,6 +398,13 @@ class Gbs(cmdln.Cmdln):
                   default=None,
                   dest='upstream_tag',
                   help="Upstream tag format, e.g. 'v%(upstreamversion)s'")
+    @cmdln.option('--squash-patches-until',
+                  default=None,
+                  dest='squash_patches_until',
+                  help="When generating patches, squash patches up to given "\
+                       "commit-ish into one monolithic diff file. Format is "\
+                       "the commit-ish optionally followed by a colon and "\
+                       "diff filename base.")
     def do_build(self, _subcmd, opts, *args):
         """${cmd_name}: local build package
 
@@ -488,6 +502,13 @@ class Gbs(cmdln.Cmdln):
                   default=None,
                   dest='upstream_tag',
                   help="Upstream tag format, e.g. 'v%(upstreamversion)s'")
+    @cmdln.option('--squash-patches-until',
+                  default=None,
+                  dest='squash_patches_until',
+                  help="When generating patches, squash patches up to given "\
+                       "commit-ish into one monolithic diff file. Format is "\
+                       "the commit-ish optionally followed by a colon and "\
+                       "diff filename base.")
     def do_remotebuild(self, subcmd, opts, *args):
         """${cmd_name}: remote build package