[kteam-tools 1/2] ktl: Debian.changelog(local=False) param
Andy Whitcroft
apw at canonical.com
Sun Dec 20 14:46:38 UTC 2015
On Fri, Dec 18, 2015 at 10:55:14AM -0800, Kamal Mostafa wrote:
> Debian.changelog() and Debian.raw_changelog() now accept a bool param 'local'.
>
> When called with local=False the committed version of the changelog is parsed
> (this the default, matching old behavior).
>
> When called with local=True, the local copy of the changelog (possibly locally
> modified) is parsed instead.
>
> It may make even more sense to switch the default behavior to local=True but
> that's not done here. This commit introduces no functional change.
>
> Signed-off-by: Kamal Mostafa <kamal at canonical.com>
> ---
> ktl/debian.py | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/ktl/debian.py b/ktl/debian.py
> index ef4888b..9b73886 100644
> --- a/ktl/debian.py
> +++ b/ktl/debian.py
> @@ -85,7 +85,7 @@ class Debian:
> # raw_changelog
> #
> @classmethod
> - def raw_changelog(cls):
> + def raw_changelog(cls, local=False):
> retval = []
>
> # Find the correct changelog for this branch of this repository.
> @@ -98,9 +98,12 @@ class Debian:
> chglog = debdir + '/changelog'
> debug("Trying '%s': " % chglog, cls.debug)
> try:
> - retval = Git.show(chglog, branch=current_branch)
> - return retval, chglog
> - except GitError:
> + if local:
> + changelog_contents = open(chglog, 'r').read().split('\n')
> + else:
> + changelog_contents = Git.show(chglog, branch=current_branch)
> + return changelog_contents, chglog
> + except:
This seems to loosen the except to everything which makes debugging
broken code in this section hard. I assume we could just make it pick
file open failure and giterrors or something?
> debug("FAILED\n", cls.debug, False)
>
> # Not there anywhere, barf
> @@ -109,8 +112,8 @@ class Debian:
> # changelog
> #
> @classmethod
> - def changelog(cls):
> - changelog_contents, changelog_path = cls.raw_changelog()
> + def changelog(cls, local=False):
> + changelog_contents, changelog_path = cls.raw_changelog(local)
> return cls.changelog_as_list(changelog_contents)
>
> # changelog_as_list
-apw
More information about the kernel-team
mailing list