[Treepkg-commits] r179 - in trunk: bin test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Apr 14 14:45:12 CEST 2009
Author: bh
Date: 2009-04-14 14:45:12 +0200 (Tue, 14 Apr 2009)
New Revision: 179
Modified:
trunk/bin/listpackages.py
trunk/test/test_listpackages.py
Log:
Add --newest=N option to listpackages to get more than one newest
revision. Add corresponding tests.
Modified: trunk/bin/listpackages.py
===================================================================
--- trunk/bin/listpackages.py 2009-04-14 09:41:59 UTC (rev 178)
+++ trunk/bin/listpackages.py 2009-04-14 12:45:12 UTC (rev 179)
@@ -30,6 +30,8 @@
help=("List source packages"))
parser.add_option("--binary", action="store_true",
help=("List binary packages"))
+ parser.add_option("--newest", type="int",
+ help=("List binary packages"))
return parser.parse_args()
def parse_revision(raw_revision):
@@ -55,7 +57,7 @@
return formatted
-def list_track_packages(track, revision, source, binary):
+def list_track_packages(track, revision, num_newest, source, binary):
main_rev, rules_rev = revision
revisions = track.get_revisions()
@@ -64,36 +66,35 @@
revisions = sorted(revisions, key=lambda r: r.status.start, reverse=True)
+ candidates = []
+
if main_rev is None:
- filtered = [revpkg for revpkg in revisions
- if revpkg.status.status.finished
- and not revpkg.status.status.error]
- if filtered:
- revpkg = filtered[0]
- else:
- revpkg = None
+ candidates = [revpkg for revpkg in revisions
+ if revpkg.status.status.finished
+ and not revpkg.status.status.error]
+ if num_newest is None:
+ num_newest = 1
+ candidates = candidates[:num_newest]
else:
- # iterate in reverse, so that we pick up the newest revision
- # packager with the desired revision first if rules_rev is None
for revpkg in revisions:
if revpkg.revision == main_rev:
if rules_rev is None or revpkg.rules_revision == rules_rev:
+ candidates = [revpkg]
break
else:
- revpkg = None
+ print >>sys.stderr, "No revision", format_revision(main_rev,
+ rules_rev)
+ sys.exit(1)
- if revpkg is not None:
+ for revpkg in candidates:
if source:
for filename in revpkg.list_source_files():
print filename
if binary:
for filename in revpkg.list_binary_files():
print filename
- else:
- print >>sys.stderr, "No revision", format_revision(main_rev, rules_rev)
- sys.exit(1)
-def list_packages(config_file, trackname, revision, source, binary):
+def list_packages(config_file, trackname, revision, num_newest, source, binary):
group = get_packager_group(config_file)
tracks = group.get_package_tracks()
if trackname is not None:
@@ -102,12 +103,13 @@
print >>sys.stderr, "no track named", trackname
sys.exit(1)
for track in tracks:
- list_track_packages(track, revision, source, binary)
+ list_track_packages(track, revision, num_newest, source, binary)
def main():
options, args = parse_commandline()
options.revision = parse_revision(options.revision)
list_packages(options.config_file, options.track, options.revision,
+ num_newest=options.newest,
source=options.source, binary=options.binary)
main()
Modified: trunk/test/test_listpackages.py
===================================================================
--- trunk/test/test_listpackages.py 2009-04-14 09:41:59 UTC (rev 178)
+++ trunk/test/test_listpackages.py 2009-04-14 12:45:12 UTC (rev 179)
@@ -225,6 +225,53 @@
kdepimlibs/pkg/803692-4322/binary/kdepimlibs_1.0.1.803692-1_i386.deb""")
+class TestListPackagesNNewest(ListPackagesTest):
+
+ track_files = [package_track_files("kdepim", "1.0.1",
+ ["kdepim", "kleopatra"],
+ [(701865, 28),
+ (700345, 28),
+ (702432, 28),
+ (704195, 31, "error")]),
+ package_track_files("kdepimlibs", "1.0.1",
+ ["kdepimlibs"],
+ [(700298, 34),
+ (700345, 34),
+ (701866, 34, "error"),
+ (701866, 35),
+ (702436, 35)]),
+ ]
+
+ def test_listpackages_source(self):
+ self.check_cmd(["--source", "--newest=2"],
+ """\
+kdepim/pkg/700345-28/src/kdepim_1.0.1.700345-1.diff.gz
+kdepim/pkg/700345-28/src/kdepim_1.0.1.700345-1.dsc
+kdepim/pkg/700345-28/src/kdepim_1.0.1.700345.orig.tar.gz
+kdepim/pkg/702432-28/src/kdepim_1.0.1.702432-1.diff.gz
+kdepim/pkg/702432-28/src/kdepim_1.0.1.702432-1.dsc
+kdepim/pkg/702432-28/src/kdepim_1.0.1.702432.orig.tar.gz
+kdepimlibs/pkg/701866-35/src/kdepimlibs_1.0.1.701866-1.diff.gz
+kdepimlibs/pkg/701866-35/src/kdepimlibs_1.0.1.701866-1.dsc
+kdepimlibs/pkg/701866-35/src/kdepimlibs_1.0.1.701866.orig.tar.gz
+kdepimlibs/pkg/702436-35/src/kdepimlibs_1.0.1.702436-1.diff.gz
+kdepimlibs/pkg/702436-35/src/kdepimlibs_1.0.1.702436-1.dsc
+kdepimlibs/pkg/702436-35/src/kdepimlibs_1.0.1.702436.orig.tar.gz""")
+
+ def test_listpackages_binary(self):
+ self.check_cmd(["--binary", "--newest=3"],
+ """\
+kdepim/pkg/700345-28/binary/kdepim_1.0.1.700345-1_i386.deb
+kdepim/pkg/700345-28/binary/kleopatra_1.0.1.700345-1_i386.deb
+kdepim/pkg/701865-28/binary/kdepim_1.0.1.701865-1_i386.deb
+kdepim/pkg/701865-28/binary/kleopatra_1.0.1.701865-1_i386.deb
+kdepim/pkg/702432-28/binary/kdepim_1.0.1.702432-1_i386.deb
+kdepim/pkg/702432-28/binary/kleopatra_1.0.1.702432-1_i386.deb
+kdepimlibs/pkg/700345-34/binary/kdepimlibs_1.0.1.700345-1_i386.deb
+kdepimlibs/pkg/701866-35/binary/kdepimlibs_1.0.1.701866-1_i386.deb
+kdepimlibs/pkg/702436-35/binary/kdepimlibs_1.0.1.702436-1_i386.deb""")
+
+
class TestListPackagesTrackRevision(ListPackagesTest):
track_files = [package_track_files("kdepim", "1.0.1",
More information about the Treepkg-commits
mailing list