tags 172113 +patch thanks Attached is a git patch against 275e47e8.
Regards, Cascardo.
From bc96cc3552ef6435d970b6909ed2cd9591ecea04 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo <[email protected]> Date: Tue, 13 Jan 2009 17:12:28 -0200 Subject: [PATCH] Introduce --reverse option That will show changes in ascending version order from top to bottom. --- apt-listchanges.py | 2 +- apt-listchanges/ALCConfig.py | 7 +++++-- apt-listchanges/DebianFiles.py | 12 +++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apt-listchanges.py b/apt-listchanges.py index bfca1da..bf734a8 100755 --- a/apt-listchanges.py +++ b/apt-listchanges.py @@ -132,7 +132,7 @@ def main(): srcversion)) continue - (news, changelog) = pkg.extract_changes(config.which, fromversion) + (news, changelog) = pkg.extract_changes(config.which, fromversion, config.reverse) if news or changelog: found[srcpackage] = 1 diff --git a/apt-listchanges/ALCConfig.py b/apt-listchanges/ALCConfig.py index 221909e..1f490a8 100644 --- a/apt-listchanges/ALCConfig.py +++ b/apt-listchanges/ALCConfig.py @@ -47,6 +47,7 @@ class ALCConfig: self.which = 'both' self.allowed_which = ('both', 'news', 'changelogs') self.since = None + self.reverse = False def read(self, file): self.parser = ConfigParser.ConfigParser() @@ -57,7 +58,7 @@ class ALCConfig: for option in self.parser.options(self.profile): value = None if self.parser.has_option(self.profile, option): - if option in ('confirm', 'run', 'show_all', 'headers', 'verbose'): + if option in ('confirm', 'run', 'show_all', 'headers', 'verbose', 'reverse'): value = self.parser.getboolean(self.profile, option) else: value = self.parser.get(self.profile, option) @@ -81,7 +82,7 @@ class ALCConfig: (optlist, args) = getopt.getopt(argv[1:], 'vf:s:cah', [ "apt", "verbose", "frontend=", "email-address=", "confirm", "all", "headers", "save_seen=", "since=", "debug", "which=", - "help", "profile="]) + "help", "profile=", "reverse"]) except getopt.GetoptError: return None @@ -134,6 +135,8 @@ class ALCConfig: sys.exit(1) elif opt == '--debug': self.debug = 1 + elif opt == '--reverse': + self.reverse = 1 if self.email_address == 'none': self.email_address = None diff --git a/apt-listchanges/DebianFiles.py b/apt-listchanges/DebianFiles.py index 4bc9c58..1055eb0 100644 --- a/apt-listchanges/DebianFiles.py +++ b/apt-listchanges/DebianFiles.py @@ -110,7 +110,7 @@ class Package: self.source = pkgdata.source() self.Version = pkgdata.Version - def extract_changes(self, which, since_version=None): + def extract_changes(self, which, since_version=None, reverse=None): '''Extract changelog entries, news or both from the package. If since_version is specified, only return entries later than the specified version. returns a sequence of Changes objects.''' @@ -128,7 +128,7 @@ class Package: tempdir = self.extract_contents(filenames) - find_first = lambda acc, fname: acc or self.read_changelog(os.path.join(tempdir, fname), since_version) + find_first = lambda acc, fname: acc or self.read_changelog(os.path.join(tempdir, fname), since_version, reverse) news = reduce(find_first, news_filenames, None) changelog = reduce(find_first, changelog_filenames + changelog_filenames_native, None) @@ -151,7 +151,7 @@ class Package: return tempdir - def read_changelog(self, filename, since_version): + def read_changelog(self, filename, since_version, reverse=False): filenames = glob.glob(filename) fd = None @@ -175,10 +175,13 @@ class Package: urgency = numeric_urgency('low') changes = '' + rev = [] is_debian_changelog = 0 for line in fd.readlines(): match = self.changelog_header.match(line) if match: + rev += [changes] + changes = '' is_debian_changelog = 1 if since_version: if apt_pkg.VersionCompare(match.group('version'), @@ -192,6 +195,9 @@ class Package: if not is_debian_changelog: return None + if reverse: + rev.reverse() + changes = "".join(rev) return Changes(self.source, changes, urgency) def _changelog_variations(self, filename): -- 1.6.0.6
signature.asc
Description: Digital signature

