Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
I rebased my patches on the latest experimental. The shortlog is online[1] and a pull request is following. Regards. The following changes since commit c3c2778e922ff070ad26ebbde2e41fb0d49ea9ea: Add debian/source/format parser (2012-08-26 18:07:20 +0200) are available in the git repository at: git://git.baby-gnu.net/git-buildpackage.git tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-c3c2778 for you to fetch changes up to 9a730410930b3c5f7e99926657354dc3761a4471: Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. (2012-08-30 15:56:46 +0200) Rebased on latest experimental Daniel Dehennin (3): Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository. Add spawn_dch(), add_changelog_entry() and add_changelog_section() to gbp.deb.changelog.ChangeLog. Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. gbp/deb/changelog.py | 96 + gbp/deb/git.py | 17 +++ gbp/scripts/dch.py | 142 ...anGitRepository_guess_version_from_upstream.py} | 13 +- tests/test_Changelog.py| 85 5 files changed, 224 insertions(+), 129 deletions(-) rename tests/{03_test_dch_guess_version.py = 03_test_DebianGitRepository_guess_version_from_upstream.py} (75%) Footnotes: [1] http://git.baby-gnu.net/gitweb/?p=git-buildpackage.git;a=shortlog;h=refs/tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-c3c2778 -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgpGdz80e8mf2.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Daniel Dehennin daniel.dehen...@baby-gnu.org writes: [...] I rebased my patches on the latest experimental, the only conflict was in the addition of the as keyword in except calls. NB: the tests need devscripts, if you integrate this feature, devscripts must be added to Build-Depends for tests purposes. Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgp47M0bafwg1.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Daniel Dehennin daniel.dehen...@baby-gnu.org writes: Hello, [...] Here[1] is a new version of the patch. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. I rebased my patches on the latest experimental, the only conflict was in the addition of the as keyword in except calls. The shortlog is online[1]. This is used as base for my other contributions. Regards. Footnotes: [1] http://git.baby-gnu.net/gitweb/?p=git-buildpackage.git;a=shortlog;h=refs/tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-d3ee4b0 -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgpCJrowa1aaN.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Guido Günther a...@sigxcpu.org writes: On Sat, May 19, 2012 at 06:27:26PM +0200, Daniel Dehennin wrote: Hello, Hello, I think it's almost ready to go. Why not add it? We could extend it to keep track of the changelog contents after newly added sections, etc. Cheers, Here[1] is a new version of the patch. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. Regards. Pull request: = The following changes since commit a116edd739e9ff529058a2d9df6fe67bdb17670d: Refactor deb helpers: move PristineTar class (2012-05-25 10:45:13 +0200) are available in the git repository at: git://git.baby-gnu.net/git-buildpackage.git tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-a116edd for you to fetch changes up to 5f6c498e0454c1f0f91824ddcf6879a35be44c08: Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. (2012-05-30 21:53:22 +0200) New version on latest experimental. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. Daniel Dehennin (3): Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository. Add spawn_dch(), add_changelog_entry() and add_changelog_section() to gbp.deb.changelog.ChangeLog. Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. gbp/deb/changelog.py | 113 gbp/deb/git.py | 17 +++ gbp/scripts/dch.py | 138 +++- ...anGitRepository_guess_version_from_upstream.py} | 11 +- 4 files changed, 153 insertions(+), 126 deletions(-) rename tests/{03_test_dch_guess_version.py = 03_test_DebianGitRepository_guess_version_from_upstream.py} (76%) Patches: From 0d177f45fc429e464cc5f6128b39e44318da9710 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin daniel.dehen...@baby-gnu.org Date: Wed, 30 May 2012 21:12:41 +0200 Subject: [PATCH 1/3] Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository. * gbp/deb/git.py: Update imports. (guess_version_from_upstream): New method adapted from gbp.scripts.dch. Remove the logging. Caller is responsible of handling possible GitRepositoryError exception. * tests/03_test_DebianGitRepository_guess_version_from_upstream.py: Remove useless import. (MockGitRepository): Inherit from DebianGitRepository. (TestGuessVersionFromUpstream.test_guess_no_epoch): Convert calls of dch.guess_version_from_upstream() to DebianGitRepository version. (TestGuessVersionFromUpstream.test_guess_epoch): Ditoo. --- gbp/deb/git.py | 17 +++ ...ianGitRepository_guess_version_from_upstream.py | 49 2 files changed, 66 insertions(+) create mode 100644 tests/03_test_DebianGitRepository_guess_version_from_upstream.py diff --git a/gbp/deb/git.py b/gbp/deb/git.py index 7e13b5e..2d2dc18 100644 --- a/gbp/deb/git.py +++ b/gbp/deb/git.py @@ -19,6 +19,7 @@ import re from gbp.git import GitRepository, GitRepositoryError from gbp.deb.pristinetar import DebianPristineTar +from gbp.deb import compare_versions class DebianGitRepository(GitRepository): A git repository that holds the source of a Debian package @@ -117,6 +118,22 @@ class DebianGitRepository(GitRepository): return version return None +def guess_version_from_upstream(self, upstream_tag_format, cp): + +Guess the version based on the latest version on the upstream branch + +pattern = upstream_tag_format % dict(version='*') +tag = self.find_tag('HEAD', pattern=pattern) +version = self.tag_to_version(tag, upstream_tag_format) +if version: +if cp == None: +return %s-1 % version +if cp.has_epoch(): +version = %s:%s % (cp.epoch, version) +if compare_versions(version, cp.version) 0: +return %s-1 % version +return None + @property def pristine_tar_branch(self): diff --git a/tests/03_test_DebianGitRepository_guess_version_from_upstream.py b/tests/03_test_DebianGitRepository_guess_version_from_upstream.py new file mode 100644 index 000..ba80a3b --- /dev/null +++ b/tests/03_test_DebianGitRepository_guess_version_from_upstream.py @@ -0,0 +1,49 @@ +# vim: set
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Daniel Dehennin daniel.dehen...@baby-gnu.org writes: Guido Günther a...@sigxcpu.org writes: On Sat, May 19, 2012 at 06:27:26PM +0200, Daniel Dehennin wrote: Hello, Hello, I think it's almost ready to go. Why not add it? We could extend it to keep track of the changelog contents after newly added sections, etc. Cheers, Here[1] is a new version of the patch. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. After rebasing my create-inexistant-changelog patches on this, I figure that ChangeLog.add_section() should not manipulate repo object nor upstream_tag_format. I'll redo the patches to solve this point. Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgpLY1KmXHIt3.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Daniel Dehennin daniel.dehen...@baby-gnu.org writes: [...] Here[1] is a new version of the patch. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. After rebasing my create-inexistant-changelog patches on this, I figure that ChangeLog.add_section() should not manipulate repo object nor upstream_tag_format. I'll redo the patches to solve this point. I think it's much better now[1]. Changelog methods do not care about DebianGitRepository or options anymore. Thanks, and sorry for the noise. Pull request: = The following changes since commit a116edd739e9ff529058a2d9df6fe67bdb17670d: Refactor deb helpers: move PristineTar class (2012-05-25 10:45:13 +0200) are available in the git repository at: git://git.baby-gnu.net/git-buildpackage.git tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-a116edd-2 for you to fetch changes up to 595b774f82f69960b0e7e342ba54b31f8f2947fc: Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. (2012-05-31 01:06:06 +0200) New version on latest experimental. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch without using DebianGitRepository nor options. 3. Update gbp.scripts.dch to use new methods. Daniel Dehennin (3): Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository. Add spawn_dch(), add_changelog_entry() and add_changelog_section() to gbp.deb.changelog.ChangeLog. Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. gbp/deb/changelog.py | 98 ++ gbp/deb/git.py | 17 +++ gbp/scripts/dch.py | 140 +++- ...anGitRepository_guess_version_from_upstream.py} | 13 +- tests/test_Changelog.py| 85 5 files changed, 225 insertions(+), 128 deletions(-) rename tests/{03_test_dch_guess_version.py = 03_test_DebianGitRepository_guess_version_from_upstream.py} (75%) Patches: From 851a858d8a5ef79194929596ea1de6282b4de06b Mon Sep 17 00:00:00 2001 From: Daniel Dehennin daniel.dehen...@baby-gnu.org Date: Wed, 30 May 2012 21:12:41 +0200 Subject: [PATCH 1/3] Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository. * gbp/deb/git.py: Update imports. (guess_version_from_upstream): New method adapted from gbp.scripts.dch. Remove the logging. Caller is responsible of handling possible GitRepositoryError exception. * tests/03_test_DebianGitRepository_guess_version_from_upstream.py: Adapt 03_test_dch_guess_version.py. (MockGitRepository): Inherit from DebianGitRepository. (TestGuessVersionFromUpstream.test_guess_no_epoch): Test calls of guess_version_from_upstream(). (TestGuessVersionFromUpstream.test_guess_epoch): Ditoo with epoch in version. --- gbp/deb/git.py | 17 +++ ...ianGitRepository_guess_version_from_upstream.py | 47 2 files changed, 64 insertions(+) create mode 100644 tests/03_test_DebianGitRepository_guess_version_from_upstream.py diff --git a/gbp/deb/git.py b/gbp/deb/git.py index 7e13b5e..2d2dc18 100644 --- a/gbp/deb/git.py +++ b/gbp/deb/git.py @@ -19,6 +19,7 @@ import re from gbp.git import GitRepository, GitRepositoryError from gbp.deb.pristinetar import DebianPristineTar +from gbp.deb import compare_versions class DebianGitRepository(GitRepository): A git repository that holds the source of a Debian package @@ -117,6 +118,22 @@ class DebianGitRepository(GitRepository): return version return None +def guess_version_from_upstream(self, upstream_tag_format, cp): + +Guess the version based on the latest version on the upstream branch + +pattern = upstream_tag_format % dict(version='*') +tag = self.find_tag('HEAD', pattern=pattern) +version = self.tag_to_version(tag, upstream_tag_format) +if version: +if cp == None: +return %s-1 % version +if cp.has_epoch(): +version = %s:%s % (cp.epoch, version) +if compare_versions(version, cp.version) 0: +return %s-1 % version +return None + @property def pristine_tar_branch(self): diff --git
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Daniel Dehennin daniel.dehen...@baby-gnu.org writes: Daniel Dehennin daniel.dehen...@baby-gnu.org writes: [...] Here[1] is a new version of the patch. The path is splited in 3 parts, nosetests are OK at each steps: 1. Add guess_version_from_upstream() to gbp.deb.git.DebianGitRepository: this is required for next patch 2. Add new methods to gbp.deb.changelog.ChangeLog: they are adapted version of gbp.scripts.dch ones 3. Update gbp.scripts.dch to use new methods. After rebasing my create-inexistant-changelog patches on this, I figure that ChangeLog.add_section() should not manipulate repo object nor upstream_tag_format. I'll redo the patches to solve this point. I think it's much better now[1]. Changelog methods do not care about DebianGitRepository or options anymore. Thanks, and sorry for the noise. The patch [3/3] introduce a bug, the CommandExecFailed exception must be qualified. Here is an updated patch [3/3] which use gbpc.CommandExecFailed Thanks. From 696cf17e50e0ff8b09d8c7ec66f880686cf9d514 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin daniel.dehen...@baby-gnu.org Date: Wed, 30 May 2012 21:39:51 +0200 Subject: [PATCH] Convert gbp.scripts.dch to gbp.deb.changelog.ChangeLog method calls. * gbp/scripts/dch.py: compare_version became useless. Remove useless functions: system(), spawn_dch(), add_changelog_section(), add_changelog_entry() and guess_version_from_upstream(). Update calls accordingly. (fixup_trailer): Use spawn_dch() method of ChangeLog class. (process_options): dch_options became a list. (main): Use add_section() and add_entry() methods of ChangeLog object. Take care of upstream version since ChangeLog.add_section() does not manage it anymore. Update exception handling, ChangeLog.spawn_dch() can raise CommandExecFailed exception. * tests/03_test_dch_guess_version.py: No more gbp.scripts.dch.guess_version_from_upstream() to test. --- gbp/scripts/dch.py | 140 ++-- tests/03_test_dch_guess_version.py | 54 -- 2 files changed, 22 insertions(+), 172 deletions(-) delete mode 100644 tests/03_test_dch_guess_version.py diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index ba96631..96e9533 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -28,7 +28,6 @@ import gbp.dch as dch import gbp.log from gbp.config import GbpOptionParserDebian, GbpOptionGroup from gbp.errors import GbpError -from gbp.deb import compare_versions from gbp.deb.git import GitRepositoryError, DebianGitRepository from gbp.deb.changelog import ChangeLog, NoChangeLogError @@ -36,102 +35,6 @@ user_customizations = {} snapshot_re = re.compile(\s*\*\* SNAPSHOT build @(?Pcommit[a-z0-9]+)\s+\*\*) -def system(cmd): -try: -gbpc.Command(cmd, shell=True)() -except gbpc.CommandExecFailed: -raise GbpError - - -def spawn_dch(msg=[], author=None, email=None, newversion=False, version=None, - release=False, distribution=None, dch_options=''): - -Spawn dch - -@param author: committers name -@param email: committers email -@param newversion: start a new version -@param version: the verion to use -@param release: finalize changelog for releaze -@param distribution: distribution to use -@param dch_options: options passed verbatim to dch - -distopt = -versionopt = -env = - -if newversion: -if version: -try: -versionopt = version['increment'] -except KeyError: -versionopt = '--newversion=%s' % version['version'] -else: -versionopt = '-i' -elif release: -versionopt = --release --no-force-save-on-release -msg = None - -if author and email: -env = DEBFULLNAME=%s DEBEMAIL=%s % (author, email) - -if distribution: -distopt = --distribution=%s % distribution - -cmd = '%(env)s dch --no-auto-nmu %(distopt)s %(versionopt)s %(dch_options)s ' % locals() -if msg: -cmd += '-- [[[insert-git-dch-commit-message-here]]]' -else: -cmd += '-- ' -system(cmd) -if msg: -old_cl = open(debian/changelog, r) -new_cl = open(debian/changelog.bak, w) -for line in old_cl: -if line == * [[[insert-git-dch-commit-message-here]]]\n: -print new_cl, * + msg[0] -for line in msg[1:]: -print new_cl, + line -else: -print new_cl, line, -os.rename(debian/changelog.bak, debian/changelog) - - -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) - - -def guess_version_from_upstream(repo, upstream_tag_format, cp): - -Guess the version based on the latest version on the upstream branch - -pattern = upstream_tag_format %
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
On Sat, May 19, 2012 at 06:27:26PM +0200, Daniel Dehennin wrote: Hello, I think we can wait for #669171 to be integrated before resolving this one. I think it's almost ready to go. Why not add it? We could extend it to keep track of the changelog contents after newly added sections, etc. Cheers, -- Guido Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Guido Günther a...@sigxcpu.org writes: On Sat, May 19, 2012 at 06:27:26PM +0200, Daniel Dehennin wrote: Hello, I think we can wait for #669171 to be integrated before resolving this one. I think it's almost ready to go. Why not add it? We could extend it to keep track of the changelog contents after newly added sections, etc. The tag apply to latest experimental, I was just wondering which one to integrate first. Personally, I prefer this one getting integrated first since the use of gbp.command_wrappers.Command() and dch_options as a list are much better ;-) Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgpLUNXLiOhqp.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Hello, I think we can wait for #669171 to be integrated before resolving this one. Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF pgpUkUekzgYbx.pgp Description: PGP signature
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Hello, Here is a refreshed patch rebased on latest experimental. Regards. The following changes since commit 7fc0d8c974921d1ef280d5178d03839e0d074b88: Fix typo in doctest that made epydoc fail. (2012-05-15 21:04:23 +0200) are available in the git repository at: git://git.baby-gnu.net/git-buildpackage tags/dad/move-spawn_dch-to-ChangeLog/rebased/on-7fc0d8c for you to fetch changes up to 562d88f7686a1584f1e78e46017889b15404bc5b: Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. (2012-05-17 12:50:27 +0200) Patch rebased on latest experimental. Daniel Dehennin (1): Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. gbp/deb/changelog.py | 113 + gbp/deb/git.py | 17 + gbp/scripts/dch.py | 138 ++-- tests/03_test_dch_guess_version.py | 11 +-- 4 files changed, 153 insertions(+), 126 deletions(-) From 562d88f7686a1584f1e78e46017889b15404bc5b Mon Sep 17 00:00:00 2001 From: Daniel Dehennin daniel.dehen...@baby-gnu.org Date: Mon, 14 May 2012 18:15:06 +0200 Subject: [PATCH] Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. This require the move of gbp.scripts.guess_version_from_upstream to gbp.deb.git.DebianGitRepository. spawn_dch use gbp.command.wrappers.Command, this require the change of dch_options from string to list. * tests/03_test_dch_guess_version.py: Make MockGitRepository inherits from DebianGitRepository since guess_version_from_upstream became a method of DebianGitRepository. Update calls to guess_version_from_upstream accordingly. * gbp/deb/changelog.py (ChangeLog.spawn_dch): static method imported from gbp.scripts.dch and converted to gbp.command_wrappers.Command. (add_entry): New method imported from gbp.scripts.dch.add_changelog_entry. (add_section): New method imported from gbp.scripts.dch.add_changelog_entry. Replace options argument by direct upstream_tag_format. * gbp/deb/git.py: Update imports. (guess_version_from_upstream): New method imported from gbp.scripts.dch. Remove the logging. Caller is responsible of handling possible GitRepositoryError exception. * gbp/scripts/dch.py: Remove useless import. Remove unused functions. (process_options): dch_options is now a list. (main): Update calls to spawn_dch() to ChangeLog.spawn_dch(). Update calls to add_changelog_entry() to ChangeLog.add_entry(). Update calls to add_changelog_section() to ChangeLog.add_section(). Catch CommandExecFailed exception. --- gbp/deb/changelog.py | 113 + gbp/deb/git.py | 17 + gbp/scripts/dch.py | 138 ++-- tests/03_test_dch_guess_version.py | 11 +-- 4 files changed, 153 insertions(+), 126 deletions(-) diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index 7dc51d9..97ca77b 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -19,6 +19,7 @@ import email import os import subprocess +from gbp.command_wrappers import Command class NoChangeLogError(Exception): No changelog found @@ -204,3 +205,115 @@ class ChangeLog(object): Get sections in the changelog return list(self.sections_iter) + +@staticmethod +def spawn_dch(msg=[], author=None, email=None, newversion=False, version=None, + release=False, distribution=None, dch_options=[]): + +Spawn dch + +@param author: committers name +@type author: C{str} +@param email: committers email +@type email: C{str} +@param newversion: start a new version +@type newversion: C{bool} +@param version: the verion to use +@type version: C{str} +@param release: finalize changelog for releaze +@type release: C{bool} +@param distribution: distribution to use +@type distribution: C{str} +@param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} + +distopt = +versionopt = +env = +args = ['--no-auto-nmu'] +if newversion: +if version: +try: +args.append(version['increment']) +except KeyError: +args.append('--newversion=%s' % version['version']) +else: +args.append('-i') +elif release: +args.append(--release --no-force-save-on-release) +msg = None + +if author and
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Tags: patch #secure method=pgpmime mode=sign Hello, I made a new version of the patch which include methods documentations and avoid passing all the options to ChangeLog.add_section(). Following are: - diff to previous version: git diff dad/move-spawn_dch-to-ChangeLog..dad/move-spawn_dch-to-ChangeLog-1 - pull request - patch for review: full patch of the new version Regards. Diff to previous version: = diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index 3ab259d..7ad2804 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -156,12 +156,21 @@ class ChangeLog(object): Spawn dch @param author: committers name +@type author: C{str} @param email: committers email +@type email: C{str} @param newversion: start a new version +@type newversion: C{bool} @param version: the verion to use +@type version: C{str} @param release: finalize changelog for releaze +@type release: C{bool} @param distribution: distribution to use +@type distribution: C{str} @param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} distopt = versionopt = @@ -191,7 +200,7 @@ class ChangeLog(object): args.append('[[[insert-git-dch-commit-message-here]]]') else: args.append('') -dch = Command('dch', args, shell=True, extra_env=env) +dch = Command('dch', args, extra_env=env) dch.call([]) if msg: old_cl = open(debian/changelog, r) @@ -205,15 +214,47 @@ class ChangeLog(object): print new_cl, line, os.rename(debian/changelog.bak, debian/changelog) -def add_entry(self, msg, author, email, dch_options): -Add a single changelog entry +def add_entry(self, msg, author=None, email=None, dch_options=[]): +Add a single changelog entry + +@param msg: log message to add +@type msg: C{str} +@param author: name of the author of the log message +@type author: C{str} +@param email: email of the author of the log message +@type email: C{str} +@param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} + self.spawn_dch(msg=msg, author=author, email=email, dch_options=dch_options) -def add_section(self, msg, distribution, repo, options, -author=None, email=None, version={}, dch_options=''): -Add a new section to the changelog +def add_section(self, msg, distribution, repo, upstream_tag_format='', +author=None, email=None, version={}, dch_options=[]): +Add a new section to the changelog + +@param msg: log message to add +@type msg: C{str} +@param distribution: distribution to set for the new changelog entry +@type distribution: C{str} +@param repo: git repository we are operating on +@type repo: C{gbp.deb.git.DebianRepository} +@param upstream_tag_format: format use to find upstream tag +@type upstream_tag_format: C{str} +@param author: name of the author of the log message +@type author: C{str} +@param email: email of the author of the log message +@type email: C{str} +@param version: version to set for the new changelog entry +@param version: C{dict} +@param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} + if not version and not self.is_native(): -v = repo.guess_version_from_upstream(options.upstream_tag, self) +v = repo.guess_version_from_upstream(upstream_tag_format, self) if v: version['version'] = v self.spawn_dch(msg=msg, newversion=True, version=version, author=author, diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 4eb32ed..ee1c075 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -391,7 +391,7 @@ def main(argv): email=commit_email, dch_options=dch_options, repo=repo, - options=options) + upstream_tag_format=options.upstream_tag) # Adding a section only needs to happen once. add_section = False else: @@ -410,7 +410,7 @@ def main(argv): version=version_change, dch_options=dch_options, repo=repo, - options=options) +
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Hi, On Tue, May 15, 2012 at 08:21:30AM +0200, Daniel Dehennin wrote: Tags: patch #secure method=pgpmime mode=sign Hello, I made a new version of the patch which include methods documentations and avoid passing all the options to ChangeLog.add_section(). Following are: - diff to previous version: git diff dad/move-spawn_dch-to-ChangeLog..dad/move-spawn_dch-to-ChangeLog-1 - pull request - patch for review: full patch of the new version Thanks! Please don't stack patches that fixup previous versions but send a new version instead since it makes reviewing things much harder otherwise. Cheers, -- Guido Regards. Diff to previous version: = diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index 3ab259d..7ad2804 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -156,12 +156,21 @@ class ChangeLog(object): Spawn dch @param author: committers name +@type author: C{str} @param email: committers email +@type email: C{str} @param newversion: start a new version +@type newversion: C{bool} @param version: the verion to use +@type version: C{str} @param release: finalize changelog for releaze +@type release: C{bool} @param distribution: distribution to use +@type distribution: C{str} @param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} distopt = versionopt = @@ -191,7 +200,7 @@ class ChangeLog(object): args.append('[[[insert-git-dch-commit-message-here]]]') else: args.append('') -dch = Command('dch', args, shell=True, extra_env=env) +dch = Command('dch', args, extra_env=env) dch.call([]) if msg: old_cl = open(debian/changelog, r) @@ -205,15 +214,47 @@ class ChangeLog(object): print new_cl, line, os.rename(debian/changelog.bak, debian/changelog) -def add_entry(self, msg, author, email, dch_options): -Add a single changelog entry +def add_entry(self, msg, author=None, email=None, dch_options=[]): +Add a single changelog entry + +@param msg: log message to add +@type msg: C{str} +@param author: name of the author of the log message +@type author: C{str} +@param email: email of the author of the log message +@type email: C{str} +@param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} + self.spawn_dch(msg=msg, author=author, email=email, dch_options=dch_options) -def add_section(self, msg, distribution, repo, options, -author=None, email=None, version={}, dch_options=''): -Add a new section to the changelog +def add_section(self, msg, distribution, repo, upstream_tag_format='', +author=None, email=None, version={}, dch_options=[]): +Add a new section to the changelog + +@param msg: log message to add +@type msg: C{str} +@param distribution: distribution to set for the new changelog entry +@type distribution: C{str} +@param repo: git repository we are operating on +@type repo: C{gbp.deb.git.DebianRepository} +@param upstream_tag_format: format use to find upstream tag +@type upstream_tag_format: C{str} +@param author: name of the author of the log message +@type author: C{str} +@param email: email of the author of the log message +@type email: C{str} +@param version: version to set for the new changelog entry +@param version: C{dict} +@param dch_options: options passed verbatim to dch +@type dch_options: C{list} +@return: return code of dch subprocess +@rtype: C{int} + if not version and not self.is_native(): -v = repo.guess_version_from_upstream(options.upstream_tag, self) +v = repo.guess_version_from_upstream(upstream_tag_format, self) if v: version['version'] = v self.spawn_dch(msg=msg, newversion=True, version=version, author=author, diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 4eb32ed..ee1c075 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -391,7 +391,7 @@ def main(argv): email=commit_email, dch_options=dch_options, repo=repo, - options=options) + upstream_tag_format=options.upstream_tag) #
Bug#672954: git-buildpackage: Move spawn_dch from gbp.scripts.dch to gbp.deb.changelog.ChangeLog
Package: git-buildpackage Version: 0.6.0~git20120419 Severity: wishlist Dear Maintainer, Here is my first proposal of moving some gbp.scripts.dch functions to reusable places. Included is a pull request and a patch for review. Regards. The following changes since commit c57d4af675910ec151cf982532db0f877aef413f: gbp.git.repository: Add a git merge-base wrapper (2012-05-14 13:16:15 +0200) are available in the git repository at: git://git.baby-gnu.org/git-buildpackage tags/dad/move-spawn_dch-to-ChangeLog for you to fetch changes up to a141d79488cc5b24d295d864a2f0c164e3933ace: Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. (2012-05-15 00:27:07 +0200) First proposal for review based on actual experimental. Daniel Dehennin (1): Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. gbp/deb/changelog.py | 70 ++ gbp/deb/git.py | 17 + gbp/scripts/dch.py | 138 ++-- tests/03_test_dch_guess_version.py | 11 +-- 4 files changed, 110 insertions(+), 126 deletions(-) From a141d79488cc5b24d295d864a2f0c164e3933ace Mon Sep 17 00:00:00 2001 From: Daniel Dehennin daniel.dehen...@baby-gnu.org Date: Mon, 14 May 2012 18:15:06 +0200 Subject: [PATCH] Move spawn_dch, add_changelog_entry and add_changelog_section from gbp.scripts.dch to gbp.deb.changelog.ChangeLog. This require the move of gbp.scripts.guess_version_from_upstream to gbp.deb.git.DebianGitRepository. spawn_dch use gbp.command.wrappers.Command, this require the change of dch_options from string to list. * tests/03_test_dch_guess_version.py: Make MockGitRepository inherits from DebianGitRepository since guess_version_from_upstream became a method of DebianGitRepository. Update calls to guess_version_from_upstream accordingly. * gbp/deb/changelog.py (ChangeLog.spawn_dch): static method imported from gbp.scripts.dch and converted to gbp.command_wrappers.Command. (add_entry): New method imported from gbp.scripts.dch.add_changelog_entry. (add_section): New method imported from gbp.scripts.dch.add_changelog_entry. * gbp/deb/git.py: Update imports. (guess_version_from_upstream): New method imported from gbp.scripts.dch. Remove the logging. Caller is responsible of handling possible GitRepositoryError exception. * gbp/scripts/dch.py: Remove useless import. Remove unused functions. (process_options): dch_options is now a list. (main): Update calls to spawn_dch() to ChangeLog.spawn_dch(). Update calls to add_changelog_entry() to ChangeLog.add_entry(). Update calls to add_changelog_section() to ChangeLog.add_section(). Catch CommandExecFailed exception. --- gbp/deb/changelog.py | 70 ++ gbp/deb/git.py | 17 + gbp/scripts/dch.py | 138 ++-- tests/03_test_dch_guess_version.py | 11 +-- 4 files changed, 110 insertions(+), 126 deletions(-) diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index b8c10b8..3ab259d 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -19,6 +19,7 @@ import email import os import subprocess +from gbp.command_wrappers import Command class NoChangeLogError(Exception): No changelog found @@ -148,3 +149,72 @@ class ChangeLog(object): return self._cp['Date'] +@staticmethod +def spawn_dch(msg=[], author=None, email=None, newversion=False, version=None, + release=False, distribution=None, dch_options=[]): + +Spawn dch + +@param author: committers name +@param email: committers email +@param newversion: start a new version +@param version: the verion to use +@param release: finalize changelog for releaze +@param distribution: distribution to use +@param dch_options: options passed verbatim to dch + +distopt = +versionopt = +env = +args = ['--no-auto-nmu'] +if newversion: +if version: +try: +args.append(version['increment']) +except KeyError: +args.append('--newversion=%s' % version['version']) +else: +args.append('-i') +elif release: +args.append(--release --no-force-save-on-release) +msg = None + +if author and email: +env = {'DEBFULLNAME': author, 'DEBEMAIL': email} + +if distribution: +args.append(--distribution=%s % distribution) + +args.extend(dch_options) +args.append('--') +if msg: +