aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChris Lamb <lamby@debian.org>2017-08-16 18:28:16 -0700
committerGuido Günther <agx@sigxcpu.org>2017-08-22 08:15:47 +0200
commitf97b910ca2b149c862636b8e7dcf6211d2ad7f0e (patch)
treeb1155da09c21b700edbb655cc298c633c8131145
parente5be6028e4918dee9a958b16fea2ba701f004feb (diff)
pq: make --abbrev= configurable
Closes: #872351 Signed-off-by: Guido Günther <agx@sigxcpu.org>
-rw-r--r--docs/manpages/gbp-pq-rpm.sgml13
-rw-r--r--docs/manpages/gbp-pq.sgml13
-rw-r--r--gbp/config.py5
-rw-r--r--gbp/scripts/common/pq.py8
-rwxr-xr-xgbp/scripts/pq.py4
-rwxr-xr-xgbp/scripts/pq_rpm.py7
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">
@@ -158,6 +159,18 @@
</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>
<para>
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>
@@ -201,6 +202,18 @@
</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>
<para>In case of <option>import</option>, import even if the
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 8cf73852..cf693576 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")