Hi, thanks for your patch. Creating the missing changelog might make sense but it shouldn't mangle all the code but be confined to one place (create the changelog and reread it).
On Wed, Apr 18, 2012 at 12:05:30AM +0200, Daniel Dehennin wrote: > diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py > index 3a4a02a..2b060d1 100644 > --- a/gbp/scripts/dch.py > +++ b/gbp/scripts/dch.py > @@ -112,9 +112,9 @@ def guess_version_from_upstream(repo, > upstream_tag_format, cp): > version = repo.tag_to_version(tag, upstream_tag_format) > if version: > gbp.log.debug("Found upstream version %s." % version) > - if cp.has_epoch(): > + if hasattr(cp, 'has_epoch') and cp.has_epoch(): This shouldn't be needed (see below) > version = "%s:%s" % (cp.epoch, version) > - if compare_versions(version, cp.version) > 0: > + if compare_versions(version, cp['Version']) > 0: This shouldn't be needed (see below) > return "%s-1" % version > except GitRepositoryError: > gbp.log.debug("No tag found matching pattern %s." % pattern) > @@ -124,7 +124,7 @@ def guess_version_from_upstream(repo, > upstream_tag_format, cp): > def add_changelog_section(msg, distribution, repo, options, cp, > author=None, email=None, version={}, > dch_options=''): > """Add a new section to the changelog""" > - if not version and not cp.is_native(): > + if not version and not (hasattr(cp,'is_native') and cp.is_native()): This shouldn't be needed (see below) > v = guess_version_from_upstream(repo, options.upstream_tag, cp) > if v: > version['version'] = v > @@ -270,7 +270,7 @@ def guess_snapshot_commit(cp, repo, options): > # If the current topmost changelog entry has already been tagged rely on > # the version information only. The upper level relies then on the > version > # info anyway: > - if repo.find_version(options.debian_tag, cp.version): > + if repo.find_version(options.debian_tag, cp['Version']): This shouldn't be needed (see below) > return None > # If we didn't find a snapshot header we look at the point the changelog > # was last touched. > @@ -416,7 +416,12 @@ def main(argv): > gbp.log.err("You are not on branch '%s' but on '%s'" % > (options.debian_branch, branch)) > raise GbpError, "Use --ignore-branch to ignore or > --debian-branch to set the branch name." > > - cp = ChangeLog(filename=changelog) > + try: > + cp = ChangeLog(filename=changelog) > + except NoChangeLogError, err: > + gbp.log.info("No debian/changelog: create a new one") > + cp = {'Changes': '', 'Version': ''} > + dch_options += " --create" If you do this create a proper changelog object (and add tests!) since this would make all the check superfluous. If needed run dch --create eralier. Cheers, -- Guido > > if options.since: > since = options.since > @@ -429,7 +434,7 @@ def main(argv): > found_snapshot_header = True > else: > gbp.log.info("Couldn't find snapshot header, using > version info") > - if not since: > + if dch_options.find(" --create") == -1 and not since: > since = repo.find_version(options.debian_tag, cp['Version']) > if not since: > raise GbpError, "Version %s not found" % cp['Version'] > @@ -441,14 +446,14 @@ def main(argv): > commits.reverse() > > # add a new changelog section if: > - if options.new_version or options.bpo or options.nmu or options.qa: > + if options.new_version or options.bpo or options.nmu or options.qa > or dch_options.find(" --create") != -1: > if options.bpo: > version_change['increment'] = '--bpo' > elif options.nmu: > version_change['increment'] = '--nmu' > elif options.qa: > version_change['increment'] = '--qa' > - else: > + elif dch_options.find(" --create") == -1: > version_change['version'] = options.new_version > # the user wants to force a new version > add_section = True > @@ -484,6 +489,8 @@ def main(argv): > cp=cp) > # Adding a section only needs to happen once. > add_section = False > + # Like creating new changelog > + dch_options = dch_options.replace(' --create', '') > else: > add_changelog_entry(commit_msg, commit_author, commit_email, > dch_options) > > @@ -516,7 +523,7 @@ def main(argv): > if editor_cmd: > gbpc.Command(editor_cmd, ["debian/changelog"])() > > - except (GbpError, GitRepositoryError, NoChangeLogError), err: > + except (GbpError, GitRepositoryError), err: > if len(err.__str__()): > gbp.log.err(err) > ret = 1 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org