Mercurial > treepkg
changeset 399:04310ad0063e treepkg-status
let the user specify num revisions that should be shown in the info
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Mon, 12 Jul 2010 12:10:34 +0000 |
parents | 09b7b7bf0b04 |
children | 48aaffdc1a4f |
files | bin/treepkginfo.py treepkg/info/status.py |
diffstat | 2 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/treepkginfo.py Fri Jul 09 15:06:15 2010 +0000 +++ b/bin/treepkginfo.py Mon Jul 12 12:10:34 2010 +0000 @@ -16,12 +16,23 @@ def parse_commandline(): parser = create_parser() + parser.set_defaults(newest=-1) + parser.add_option("--newest", type="int", + help=("Number of newest revisions to list.")) + parser.add_option("--pretty", action="store_true", help=("Show XML pretty" + " output.")) + return parser.parse_args() def main(): options, args = parse_commandline() - tpkginfo = status.TreepkgInfo(options.config_file) + tpkginfo = status.TreepkgInfo(options.config_file, options.newest) + + if options.pretty: + print tpkginfo.toxml().toprettyxml() + else: + print tpkginfo.toxml().toxml() main()
--- a/treepkg/info/status.py Fri Jul 09 15:06:15 2010 +0000 +++ b/treepkg/info/status.py Mon Jul 12 12:10:34 2010 +0000 @@ -27,7 +27,8 @@ class TreepkgInfo: - def __init__(self, config): + def __init__(self, config, numnewestrev=-1): + self.numnewestrev = numnewestrev group = get_packager_group(config) self.tpkgroot = TreepkgRootInfo(group.name, group.treepkg_dir, group.tracks_dir) @@ -43,6 +44,11 @@ def add_revisions(self, track, trackinfo): revisions = track.get_revisions() + #revisions = sorted(revisions, key=lambda r: r.status.start, + # reverse=True) + #if self.numnewestrev > 0: + # revisions = revisions[:self.numnewestrev] + for rev in revisions: revision = rev.revision rules_revision = rev.rules_revision