From: Markus Lehtonen Date: Mon, 20 Aug 2012 14:23:26 +0000 (+0300) Subject: Support squashing patches in patch generation X-Git-Tag: 0.10~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94d63cb5a72ffce379b93c4ba028454cfa4a1be5;p=tools%2Fgbs.git Support squashing patches in patch generation 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 --- diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 1298c6e..ff7dfe1 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -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"]) diff --git a/gitbuildsys/conf.py b/gitbuildsys/conf.py index 0844853..dd2a649 100644 --- a/gitbuildsys/conf.py +++ b/gitbuildsys/conf.py @@ -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', diff --git a/tools/gbs b/tools/gbs index 1073b10..f4da7e3 100755 --- 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