Hi Daniel,
thanks for your patch. Some more comments below:
On Thu, Apr 19, 2012 at 11:13:37PM +0200, Daniel Dehennin wrote:
[..snip..]
> diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
> index 3a4a02a..44a4892 100644
> --- a/gbp/scripts/dch.py
> +++ b/gbp/scripts/dch.py
> @@ -75,6 +75,11 @@ def spawn_dch(msg=[], author=None, email=None,
> newversion=False, version=None,
> if author and email:
> env = """DEBFULLNAME="%s" DEBEMAIL="%s" """ % (author, email)
>
> + if dch_options.find(" --create") != -1:
> + env += """ EDITOR=/bin/true"""
> + # Should be lower than anything?
> + dch_options += """ --newversion=0~~~~~"""
> +
We need to try harder to find a sane version here. E.g. from the
upstream tag.
> if distribution:
> distopt = "--distribution=%s" % distribution
>
> @@ -97,6 +102,17 @@ def spawn_dch(msg=[], author=None, email=None,
> newversion=False, version=None,
> os.rename("debian/changelog.bak", "debian/changelog")
>
>
> +def create_empty_changelog(changelog, repo, options):
> + """Create an empty changelog file"""
> + spawn_dch(dch_options=" --create --empty")
> + cp = ChangeLog(filename=changelog)
> + if not options.new_version:
> + cp['MangledVersion'] = guess_version_from_upstream(repo,
> options.upstream_tag, cp)
> + else:
> + cp['MangledVersion'] = options.new_version
> + mangle_changelog(changelog, cp)
> + return ChangeLog(filename=changelog)
> +
This should rather be a classmethod on deb.changelog (see e.g.
gbp.git.Repository.create. This was we can easily test this method and
reuse it elsewhere.
> def add_changelog_entry(msg, author, email, dch_options):
> """Add a single changelog entry"""
> spawn_dch(msg=msg, author=author, email=email, dch_options=dch_options)
> @@ -416,7 +432,13 @@ 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)
> + created_cp = False
> + try:
> + cp = ChangeLog(filename=changelog)
> + except NoChangeLogError, err:
> + gbp.log.info("No debian/changelog: create a new one")
> + cp = create_empty_changelog(changelog, repo, options)
> + created_cp = True
We don't need created_cp if we have create a real ChangeLog object (see
above).
>
> if options.since:
> since = options.since
> @@ -429,7 +451,7 @@ def main(argv):
> found_snapshot_header = True
> else:
> gbp.log.info("Couldn't find snapshot header, using
> version info")
> - if not since:
> + if not created_cp and not since:
If we get the above right repo.find_versions should return nothing and
be a noop so we can leave out the comparision.
> since = repo.find_version(options.debian_tag, cp['Version'])
> if not since:
> raise GbpError, "Version %s not found" % cp['Version']
> @@ -441,7 +463,7 @@ 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 not created_cp and (options.new_version or options.bpo or
> options.nmu or options.qa):
Don't we want to honor these options?
> if options.bpo:
> version_change['increment'] = '--bpo'
> elif options.nmu:
> Footnotes:
> [1] I need to look at how to add a test in the test suit
Great. The above comments should make it easier.
Cheers,
-- Guido
>
> --
> Daniel Dehennin
> Récupérer ma clef GPG:
> gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]