Hi, On Wed, Aug 16, 2017 at 06:28:16PM -0700, Chris Lamb wrote: > Hi Guido, > > > Thanks! Can you update docs/manpages/gbp-pq{,-rpm}.sgml as well? > > With pleasure. Updated patch attached.
Thanks for the update. I've fixed a syntax error in config.py (attached) but afterwards there are still test suite errors. I'll have look once back from vacation. Cheers, -- Guido
>From 75e18fc5bb4831df924bc708130b0a6ab311a230 Mon Sep 17 00:00:00 2001 Message-Id: <75e18fc5bb4831df924bc708130b0a6ab311a230.1502933971.git....@sigxcpu.org> From: Chris Lamb <la...@debian.org> Date: Wed, 16 Aug 2017 18:28:16 -0700 Subject: [PATCH] pq: make --abbrev= configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #872351 Signed-off-by: Guido Günther <a...@sigxcpu.org> --- docs/manpages/gbp-pq-rpm.sgml | 13 +++++++++++++ docs/manpages/gbp-pq.sgml | 13 +++++++++++++ gbp/config.py | 5 ++++- gbp/scripts/common/pq.py | 8 ++++---- gbp/scripts/pq.py | 4 +++- gbp/scripts/pq_rpm.py | 7 ++++--- 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/docs/manpages/gbp-pq-rpm.sgml b/docs/manpages/gbp-pq-rpm.sgml index 63a8501a..b8535e6f 100644 --- a/docs/manpages/gbp-pq-rpm.sgml +++ b/docs/manpages/gbp-pq-rpm.sgml @@ -23,6 +23,7 @@ <arg><option>--packaging-dir=</option><replaceable>DIRECTORY</replaceable></arg> <arg><option>--spec-file=</option><replaceable>FILEPATH</replaceable></arg> <arg><option>--upstream-tag=</option><replaceable>TAG-FORMAT</replaceable></arg> + <arg><option>--abbrev=</option><replaceable>num</replaceable></arg> <arg><option>--force</option></arg> <arg><option>--[no-]patch-numbers</option></arg> <group choice="plain"> @@ -157,6 +158,18 @@ </para> </listitem> </varlistentry> + <varlistentry> + <term><option>--abbrev=</option><replaceable>NUM</replaceable> + </term> + <listitem> + <para> + When exporting a patch queue abbreviate commit, instead of showing the + full 40-byte hexadecimal object name in header lines, show only a + partial prefix of length <replaceable>NUM</replaceable>. This is + useful when existing patches were not generated by &gbp-pq;. + </para> + </listitem> + </varlistentry> <varlistentry> <term><option>--force</option></term> <listitem> diff --git a/docs/manpages/gbp-pq.sgml b/docs/manpages/gbp-pq.sgml index 9b06ca3e..3af503c0 100644 --- a/docs/manpages/gbp-pq.sgml +++ b/docs/manpages/gbp-pq.sgml @@ -26,6 +26,7 @@ <arg><option>--topic=</option><replaceable>topic</replaceable></arg> <arg><option>--time-machine=</option><replaceable>num</replaceable></arg> <arg><option>--[no-]drop</option></arg> + <arg><option>--abbrev=</option><replaceable>num</replaceable></arg> <arg><option>--force</option></arg> <arg><option>--meta-closes=bug-close-tags</option></arg> <arg><option>--meta-closes-bugnum=bug-number-format</option></arg> @@ -200,6 +201,18 @@ a successful export</para> </listitem> </varlistentry> + <varlistentry> + <term><option>--abbrev=</option><replaceable>NUM</replaceable> + </term> + <listitem> + <para> + When exporting a patch queue abbreviate commit, instead of showing the + full 40-byte hexadecimal object name in header lines, show only a + partial prefix of length <replaceable>NUM</replaceable>. This is + useful when existing patches were not generated by &gbp-pq;. + </para> + </listitem> + </varlistentry> <varlistentry> <term><option>--force</option></term> <listitem> diff --git a/gbp/config.py b/gbp/config.py index 80506090..ee44e3ff 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -101,7 +101,8 @@ class GbpOptionParser(OptionParser): @cvar def_config_files: config files we parse @type def_config_files: dict (type, path) """ - defaults = {'allow-unauthenticated': 'False', + defaults = {'abbrev': 7, + 'allow-unauthenticated': 'False', 'arch': '', 'author-date-is-committer-date': 'False', 'author-is-committer': 'False', @@ -343,6 +344,8 @@ class GbpOptionParser(OptionParser): 'drop': "In case of 'export' drop the patch-queue branch " "after export. Default is '%(drop)s'", + 'abbrev': + "abbreviate commits to this length. default is '%(abbrev)s'", 'commit': "commit changes after export, Default is '%(commit)s'", 'rollback': diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index e9502ea3..cf98a6cb 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -185,7 +185,7 @@ def write_patch_file(filename, commit_info, diff): DEFAULT_PATCH_NUM_PREFIX_FORMAT = "%04d-" -def format_patch(outdir, repo, commit_info, series, numbered=True, +def format_patch(outdir, repo, commit_info, series, abbrev, numbered=True, path_exclude_regex=None, topic='', name=None, renumber=False, patch_num_prefix_format=DEFAULT_PATCH_NUM_PREFIX_FORMAT): """Create patch of a single commit""" @@ -235,14 +235,14 @@ def format_patch(outdir, repo, commit_info, series, numbered=True, patch = None if paths: diff = repo.diff('%s^!' % commit_info['id'], paths=paths, stat=80, - summary=True, text=True, abbrev=7, renames=False) + summary=True, text=True, abbrev=abbrev, renames=False) patch = write_patch_file(filepath, commit_info, diff) if patch: series.append(patch) return patch -def format_diff(outdir, filename, repo, start, end, path_exclude_regex=None): +def format_diff(outdir, filename, repo, start, end, abbrev, path_exclude_regex=None): """Create a patch of diff between two repository objects""" info = {'author': repo.get_author_info()} @@ -260,7 +260,7 @@ def format_diff(outdir, filename, repo, start, end, path_exclude_regex=None): paths = patch_path_filter(file_status, path_exclude_regex) if paths: diff = repo.diff(start, end, paths=paths, stat=80, summary=True, - text=True, abbrev=7, renames=False) + text=True, abbrev=abbrev, renames=False) return write_patch_file(filename, info, diff) return None diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 66a8d0dc..8f7adb04 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -98,7 +98,8 @@ def generate_patches(repo, start, end, outdir, options): if 'topic' in cmds: topic = cmds['topic'] name = cmds.get('name', None) - format_patch(outdir, repo, info, patches, options.patch_numbers, + format_patch(outdir, repo, info, patches, options.abbrev, + numbered=options.patch_numbers, topic=topic, name=name, renumber=options.renumber, patch_num_prefix_format=options.patch_num_format) @@ -396,6 +397,7 @@ def build_parser(name): parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int") parser.add_boolean_config_file_option("drop", dest='drop') parser.add_boolean_config_file_option(option_name="commit", dest="commit") + parser.add_config_file_option(option_name="abbrev", dest="abbrev", type="int") parser.add_option("--force", dest="force", action="store_true", default=False, help="in case of import even import if the branch already exists") parser.add_config_file_option(option_name="color", dest="color", type='tristate') diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index ebce7ff2..9b7fb6ae 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -86,9 +86,9 @@ def generate_patches(repo, start, end, outdir, options): 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) + start_sha1 = repo.rev_parse(start, short=options.abbrev) + merge_sha1 = repo.rev_parse(merges[0], short=options.abbrev) + patch_fn = format_diff(outdir, None, repo, start_sha1, merge_sha1, options.abbrev) if patch_fn: gbp.log.info("Merge commits found! Diff between %s..%s written " "into one monolithic diff" % (start_sha1, merge_sha1)) @@ -382,6 +382,7 @@ def build_parser(name): parser.add_config_file_option(option_name="color-scheme", dest="color_scheme") parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir") + parser.add_config_file_option(option_name="abbrev", dest="abbrev", type="int") parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag") parser.add_config_file_option(option_name="spec-file", dest="spec_file") -- 2.14.0