aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2008-08-02 15:49:15 +0200
committerGuido Guenther <agx@sigxcpu.org>2008-08-02 15:49:15 +0200
commitdaf11b7cba633ee0422ce3099d8fd120ad17417f (patch)
tree02c148f0d9e8ff286786dc100c764f5f5a116890
parent5a4c2058a872f11aed3101c065f93bf68db13cdd (diff)
parent11e1d9825367657bae6b537c5dd6daba0f48464f (diff)
Merge commit 'debian/0.4.34' into bpo-etch
Conflicts: debian/changelog
-rw-r--r--debian/changelog13
-rw-r--r--docs/chapters/import.sgml1
-rw-r--r--gbp/config.py38
-rw-r--r--gbp/deb_utils.py20
-rw-r--r--gbp/git_utils.py6
-rwxr-xr-xgit-buildpackage10
-rwxr-xr-xgit-dch41
7 files changed, 91 insertions, 38 deletions
diff --git a/debian/changelog b/debian/changelog
index c4c4dcee..de9e23bb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+git-buildpackage (0.4.34) unstable; urgency=low
+
+ * [4ac0aa8] git-buildpackage: always symlink orig.tar.gz from tarball dir
+ (Closes: 490706)
+ * [fb94fea] git-buildpackage: print default export-dir on --help
+ * [ffeb40e] git-dch: escape backticks (`) (Closes: 491104)
+ * [4e398cc] git-dch: --auto and --since are incompatible
+ * [3537f24] git-dch: use option groups
+ * [18d8405] git-dch: split git-log options into a list (Closes: #479267)
+ * [044083f] docs: readd list import line (Closes: #488120)
+
+ -- Guido Guenther <agx@sigxcpu.org> Tue, 22 Jul 2008 00:29:49 -0230
+
git-buildpackage (0.4.33~bpo40+1) etch-backports; urgency=low
* Rebuild for etch-backports.
diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml
index 6b2be569..6ba388f3 100644
--- a/docs/chapters/import.sgml
+++ b/docs/chapters/import.sgml
@@ -5,6 +5,7 @@
<title>Importing already existing &debian; packages</title>
<para>Importing an already exsting debian package into a git repository is as easy as:
<screen>
+&git-import-dsc; package_0.1-1.dsc
</screen>
This will create a new git repository named after the imported package, put
the upstream sources onto the <option>upstream-branch</option> and the
diff --git a/gbp/config.py b/gbp/config.py
index b9948aca..b4d7d2e8 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -3,7 +3,7 @@
# (C) 2006,2007 Guido Guenther <agx@sigxcpu.org>
"""handles command line and config file option parsing for the gbp commands"""
-from optparse import OptionParser
+from optparse import OptionParser, OptionGroup
from ConfigParser import SafeConfigParser
import os.path
from gbp.gbp_version import gbp_version
@@ -71,6 +71,16 @@ class GbpOptionParser(OptionParser):
self.__parse_config_files()
OptionParser.__init__(self, usage=usage, version='%s %s' % (self.command, gbp_version))
+ def get_default(self, option_name, **kwargs):
+ default = self.config[option_name]
+ if kwargs.has_key('action'):
+ if kwargs['action'] in [ 'store_true', 'store_false' ] and self.config[option_name]:
+ if self.config[option_name] in [ 'True', 'False' ]:
+ default = eval(self.config[option_name])
+ else:
+ raise ValueError, "Boolean options must be True or False"
+ return default
+
def add_config_file_option(self, option_name, dest, help, **kwargs):
"""
set a option for the command line parser, the default is read from the config file
@@ -81,15 +91,23 @@ class GbpOptionParser(OptionParser):
@var help: help text
@type help: string
"""
- default = self.config[option_name]
- if kwargs.has_key('action'):
- if kwargs['action'] in [ 'store_true', 'store_false'] and self.config[option_name]:
- if self.config[option_name] in [ 'True', 'False' ]:
- default = eval(self.config[option_name])
- else:
- raise ValueError, "Boolean options must be True or False"
- OptionParser.add_option(self,"--%s%s" % (self.prefix, option_name), dest=dest,
- default=default,
+ OptionParser.add_option(self, "--%s%s" % (self.prefix, option_name), dest=dest,
+ default=self.get_default(option_name, **kwargs),
help=help % self.config, **kwargs)
+class GbpOptionGroup(OptionGroup):
+ def add_config_file_option(self, option_name, dest, help, **kwargs):
+ """
+ set a option for the command line parser, the default is read from the config file
+ @var option_name: name of the option
+ @type option_name: string
+ @var dest: where to store this option
+ @type dest: string
+ @var help: help text
+ @type help: string
+ """
+ OptionGroup.add_option(self, "--%s%s" % (self.parser.prefix, option_name), dest=dest,
+ default=self.parser.get_default(option_name, **kwargs),
+ help=help % self.parser.config, **kwargs)
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py
index a96bb8ea..e1b47483 100644
--- a/gbp/deb_utils.py
+++ b/gbp/deb_utils.py
@@ -145,18 +145,28 @@ def has_orig(cp, dir):
return False
return True
-def copy_orig(cp, orig_dir, output_dir):
- """copy orig.tar.gz from orig_dir to output_dir"""
+def symlink_orig(cp, orig_dir, output_dir, force=False):
+ """
+ symlink orig.tar.gz from orig_dir to output_dir
+ @return: True if link was created or src == dst
+ False in case of errror or src doesn't exist
+ """
orig_dir = os.path.abspath(orig_dir)
output_dir = os.path.abspath(output_dir)
if orig_dir == output_dir:
return True
+ src = os.path.join(orig_dir, orig_file(cp))
+ dst = os.path.join(output_dir, orig_file(cp))
+ if not os.access(src, os.F_OK):
+ return False
try:
- shutil.copyfile(os.path.join(orig_dir, orig_file(cp)),
- os.path.join(output_dir, orig_file(cp)))
- except IOError:
+ if os.access(dst, os.F_OK) and force:
+ os.unlink(dst)
+ print src, dst
+ os.symlink(src, dst)
+ except OSError:
return False
return True
diff --git a/gbp/git_utils.py b/gbp/git_utils.py
index 5f6158c6..13845d56 100644
--- a/gbp/git_utils.py
+++ b/gbp/git_utils.py
@@ -96,9 +96,9 @@ class GitRepository(object):
def commits(self, start, end, paths, options):
"""get commits from start to end touching pathds"""
- commits, ret = self.__git_getoutput('log', ['--pretty=format:%H',
- options, '%s..%s' % (start, end),
- '--', paths])
+ commits, ret = self.__git_getoutput('log',
+ ['--pretty=format:%H'] + options +
+ ['%s..%s' % (start, end), '--', paths])
if ret:
raise GitRepositoryError, "Error getting commits %s..%s%s" % (start, end, ["", " on %s" % paths][len(paths) > 0] )
return [ commit.strip() for commit in commits ]
diff --git a/git-buildpackage b/git-buildpackage
index 60272d98..fc3feba5 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -164,7 +164,7 @@ def main(argv):
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
help="format string for upstream tags, default is '%(upstream-tag)s'")
parser.add_config_file_option(option_name="export-dir", dest="export_dir",
- help="before building export into EXPORT_DIR")
+ help="before building export source into EXPORT_DIR, default is '%(export-dir)s'")
parser.add_config_file_option(option_name="tarball-dir", dest="tarball_dir",
help="location to look for external tarballs")
parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
@@ -241,10 +241,10 @@ def main(argv):
# Get/build the orig.tar.gz if necessary:
if not du.is_native(cp):
- # first look up if we have a tarball at tarball_dir
- if options.tarball_dir and not du.has_orig(cp, output_dir):
- print "Looking for orig tarball '%s' from '%s'" % (du.orig_file(cp), tarball_dir)
- if not du.copy_orig(cp, tarball_dir, output_dir):
+ # look in tarball_dir first, if it's there even replace an existing orig.tar.gz
+ if options.tarball_dir:
+ print "Looking for orig tarball '%s' at '%s'" % (du.orig_file(cp), tarball_dir)
+ if not du.symlink_orig(cp, tarball_dir, output_dir):
print "Orig tarball '%s' not found at '%s'" % (du.orig_file(cp), tarball_dir)
else:
print "Orig tarball '%s' found at '%s'" % (du.orig_file(cp), tarball_dir)
diff --git a/git-dch b/git-dch
index 74c41540..d0dad92b 100755
--- a/git-dch
+++ b/git-dch
@@ -25,7 +25,7 @@ import shutil
import subprocess
import gbp.command_wrappers as gbpc
from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
-from gbp.config import GbpOptionParser
+from gbp.config import GbpOptionParser, GbpOptionGroup
from gbp.errors import GbpError
from gbp.deb_utils import parse_changelog
from gbp.command_wrappers import (Command, CommandExecFailed)
@@ -41,7 +41,7 @@ def system(cmd):
def escape_commit(msg):
- return msg.replace('"','\\\"').replace("$","\$")
+ return msg.replace('"','\\\"').replace("$","\$").replace("`","\`")
def add_changelog_entry(msg, author, email):
@@ -215,35 +215,46 @@ def main(argv):
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] paths')
+ range_group = GbpOptionGroup(parser, "commit range options", "which commits to add to the changelog")
+ version_group = GbpOptionGroup(parser, "release & version number options", "what version number and release to use")
+ commit_group = GbpOptionGroup(parser, "commit message formatting", "howto format the changelog entries")
+ parser.add_option_group(range_group)
+ parser.add_option_group(version_group)
+ parser.add_option_group(commit_group)
parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
+ parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
+ help="format string for upstream tags, default is '%(upstream-tag)s'")
parser.add_config_file_option(option_name="debian-tag", dest="debian_tag",
- help="Format string for debian tags, default is '%(debian-tag)s'")
+ help="format string for debian tags, default is '%(debian-tag)s'")
parser.add_config_file_option(option_name="snapshot-number", dest="snapshot_number",
- help="Expression to determine the next snapshot number, default is '%(snapshot-number)s'")
+ help="expression to determine the next snapshot number, default is '%(snapshot-number)s'")
parser.add_config_file_option(option_name="git-log", dest="git_log",
help="options to pass to git-log, default is '%(git-log)s'")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
- parser.add_option("-s", "--since", dest="since", help="commit to start from")
- parser.add_option("-R", "--release", action="store_true", dest="release", default=False,
+ range_group.add_option("-s", "--since", dest="since", help="commit to start from (e.g. HEAD^^^, debian/0.4.3)")
+ range_group.add_option("-a", "--auto", action="store_true", dest="auto", default=False,
+ help="autocomplete changelog from last snapshot or tag")
+ version_group.add_option("-R", "--release", action="store_true", dest="release", default=False,
help="mark as release")
- parser.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False,
+ version_group.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False,
help="mark as snapshot build")
- parser.add_option("-a", "--auto", action="store_true", dest="auto", default=False,
- help="autocomplete changelog from last snapshot or tag")
- parser.add_config_file_option(option_name="meta", dest="meta",
+ commit_group.add_config_file_option(option_name="meta", dest="meta",
help="parse meta tags in commit messages, default is '%(meta)s'", action="store_true")
- parser.add_option("--full", action="store_false", dest="short", default=True,
- help="include the full commit message")
- parser.add_config_file_option(option_name="id-length", dest="idlen",
+ commit_group.add_option("--full", action="store_false", dest="short", default=True,
+ help="include the full commit message instead of only the first line")
+ commit_group.add_config_file_option(option_name="id-length", dest="idlen",
help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
type="int", metavar="N")
(options, args) = parser.parse_args(argv[1:])
if options.snapshot and options.release:
- parser.error("--snapshot and --release are incompatible options")
+ parser.error("'--snapshot' and '--release' are incompatible options")
+
+ if options.since and options.auto:
+ parser.error("'--since' and '--auto' are incompatible options")
try:
if options.verbose:
@@ -277,7 +288,7 @@ def main(argv):
if args:
print "Only looking for changes on '%s'" % " ".join(args)
- commits = repo.commits(since, until, " ".join(args), options.git_log)
+ commits = repo.commits(since, until, " ".join(args), options.git_log.split(" "))
if commits:
if cp['Distribution'] != "UNRELEASED" and not found_snapshot_header:
add_changelog_section(distribution="UNRELEASED", msg="UNRELEASED")