aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2010-12-26 23:31:57 +0100
committerGuido Günther <agx@sigxcpu.org>2010-12-27 00:02:40 +0100
commit5a312dbd55b829a3a9a5a9da5a66be9539afbd4c (patch)
treec02e84d45c7d273f1f31b32e810b7daf7113934a
parentb1f081ac53b818e20e1fe3b01bf9f06345b91638 (diff)
Allow to drop numbers from patch names via --no-patch-numbers
so patch names remain constant when interim patches are dropped. Closes: #592129
-rw-r--r--docs/manpages/gbp-pq.sgml31
-rwxr-xr-xgbp-pq27
-rw-r--r--gbp/config.py3
3 files changed, 56 insertions, 5 deletions
diff --git a/docs/manpages/gbp-pq.sgml b/docs/manpages/gbp-pq.sgml
index 0080584f..c5991146 100644
--- a/docs/manpages/gbp-pq.sgml
+++ b/docs/manpages/gbp-pq.sgml
@@ -20,6 +20,9 @@
<refsynopsisdiv>
<cmdsynopsis>
&gbp-pq;
+ <arg><option>--verbose</option></arg>
+ <arg><option>--color=</option><replaceable>[auto|on|off]</replaceable></arg>
+ <arg><option>--[no-]patch-numbers</option></arg>
<group choice="plain">
<arg><option>export</option></arg>
<arg><option>import</option></arg>
@@ -44,7 +47,7 @@
</para>
</refsect1>
<refsect1>
- <title>OPTIONS</title>
+ <title>ACTIONS</title>
<variablelist>
<varlistentry>
<term><option>import</option>
@@ -91,6 +94,32 @@
</variablelist>
</refsect1>
<refsect1>
+ <title>OPTIONS</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--verbose</option></term>
+ <term><option>-v</option></term>
+ <listitem>
+ <para>verbose execution</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--color=</option><replaceable>[auto|on|off]</replaceable>
+ </term>
+ <listitem>
+ <para>Wheter to use colored output.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--[no-]patch-numbers</option>
+ </term>
+ <listitem>
+ <para>Whether the patch files should start with a number or not.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
diff --git a/gbp-pq b/gbp-pq
index 7fbb7875..7c35a998 100755
--- a/gbp-pq
+++ b/gbp-pq
@@ -18,6 +18,8 @@
#
"""manage patches in a patch queue"""
+import errno
+import re
import os
import shutil
import subprocess
@@ -46,7 +48,9 @@ def pq_branch_base(pq_branch):
if is_pq_branch(pq_branch):
return pq_branch[len(PQ_BRANCH_PREFIX):]
-def export_patches(repo, branch):
+def export_patches(repo, branch, options):
+ patch_re = re.compile("[0-9]+-(?P<name>.+)")
+
if is_pq_branch(branch):
base = pq_branch_base(branch)
gbp.log.info("On '%s', switching to '%s'" % (branch, base))
@@ -54,7 +58,13 @@ def export_patches(repo, branch):
repo.set_branch(branch)
pq_branch = pq_branch_name(branch)
- shutil.rmtree(PATCH_DIR)
+ try:
+ shutil.rmtree(PATCH_DIR)
+ except OSError, (e, msg):
+ if e != errno.ENOENT:
+ raise GbpError, "Failed to remove patch dir: %s" % msg
+ else:
+ gbp.log.debug("%s does not exist." % PATCH_DIR)
patches = repo.format_patches(branch, pq_branch, PATCH_DIR)
if patches:
@@ -65,7 +75,15 @@ def export_patches(repo, branch):
# info) of the patch file
Command("sed -i -e '1d' -e 'N;$!P;$!D;$d' %s" % patch, shell=True)()
Command("sed -i -e 's/^-- \\n[0-9\.]+$//' %s" % patch, shell=True)()
- f.write(patch[len(PATCH_DIR):])
+
+ name = patch[len(PATCH_DIR):]
+ if not options.patch_numbers:
+ m = patch_re.match(name)
+ if m:
+ name = m.group('name')
+ shutil.move(patch, os.path.join(PATCH_DIR, name))
+
+ f.write(name + '\n')
f.close()
GitCommand('status')(['--', PATCH_DIR])
else:
@@ -141,6 +159,7 @@ def main(argv):
" rebase switch to patch queue branch associated to the current\n"
" branch and rebase against current branch.\n"
" drop drop (delete) the patch queue associated to the current branch.")
+ parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="color", dest="color")
@@ -166,7 +185,7 @@ def main(argv):
try:
current = repo.get_branch()
if action == "export":
- export_patches(repo, current)
+ export_patches(repo, current, options)
elif action == "import":
import_patches(repo, current)
elif action == "drop":
diff --git a/gbp/config.py b/gbp/config.py
index 61862f37..134d64fe 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -82,6 +82,7 @@ class GbpOptionParser(OptionParser):
'color' : 'auto',
'customizations' : '',
'spawn-editor' : 'release',
+ 'patch-numbers' : 'True',
}
help = {
'debian-branch':
@@ -134,6 +135,8 @@ class GbpOptionParser(OptionParser):
"color output, default is '%(color)s'",
'spawn-editor':
"Wether to spawn an editor after adding the changelog entry, default is '%(spawn-editor)s'",
+ 'patch-numbers':
+ "Wether to number patch files, default is %(patch-numbers)s",
}
config_files = [ '/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),