changeset 98:f7b9c7113c46

Make packaging a specific revision work even if newer revisions have already been packaged. Add corresponding tests
author Bernhard Herzog <bh@intevation.de>
date Mon, 26 Nov 2007 15:17:04 +0000
parents d85efd3276bd
children 7888fe374e11
files test/test_packager.py treepkg/packager.py
diffstat 2 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Mon Nov 26 14:45:19 2007 +0000
+++ b/test/test_packager.py	Mon Nov 26 15:17:04 2007 +0000
@@ -108,7 +108,7 @@
         for message, files in self.revisions:
             add_svn_files(self.svnworkdir, files, message)
 
-    def runtest(self, debrevision, **extra_track_args):
+    def runtest(self, debrevision, group_args=None, **extra_track_args):
         rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test",
                                "mocksudopbuilder.py")
         track = PackageTrack(name="testpkg", base_dir=self.trackdir,
@@ -117,13 +117,16 @@
                              deb_email="treepkg@example.com",
                              deb_fullname="treepkg tester",
                              **extra_track_args)
-        group = PackagerGroup([track], 1)
+
+        if group_args is None:
+            group_args = {}
+        group = PackagerGroup([track], 1, **group_args)
         group.check_package_tracks()
 
         # determine version that has been packaged.  This assumes that
         # check_package_tracks will leave the checkout in the revision
         # that was actually packaged.
-        version = subversion.last_changed_revision(self.svn_url)
+        version = track.last_changed_revision()
 
         # Now check the source and binary package files
         pkgdir = os.path.join(self.trackdir, "pkg", "%d-1" % version)
@@ -151,6 +154,24 @@
     def test_custom_debrevision_prefix(self):
         self.runtest("kk1", debrevision_prefix="kk")
 
+
+class TestPackagerWithMultipleRevisions(PackagerTest):
+
+    revisions = [
+        ("Initial Revision",
+         [("README", "and miles to go before I sleep")]),
+        ("Add some code",
+         [("program.c", "int main(void) { return 0; }")]),
+        ("Add some more code",
+         [("another.c", "int main(void) { return 1; }")]),
+        ]
+
+    def test_packaging_specific_revision(self):
+        # Package the newest revision and then package an older one.
+        self.runtest("treepkg1")
+        self.runtest("treepkg1", group_args=dict(revision=3))
+
+
 class StoppingPackager(treepkg.packager.RevisionPackager):
 
     def package(self):
--- a/treepkg/packager.py	Mon Nov 26 14:45:19 2007 +0000
+++ b/treepkg/packager.py	Mon Nov 26 15:17:04 2007 +0000
@@ -378,13 +378,13 @@
         self.update_checkout(revision=revision)
         current_revision = self.last_changed_revision()
         logging.info("New revision is %d", current_revision)
-        previous_revision = self.last_packaged_revision()
-        logging.info("Previously packaged revision was %d", previous_revision)
-        if current_revision > previous_revision:
-            logging.info("New revision has not been packaged yet")
+        if current_revision not in self.get_revision_numbers():
+            logging.info("Revision %d has not been packaged yet",
+                         current_revision)
             return self.revision_packager_cls(self, current_revision)
         else:
-            logging.info("New revision already packaged.")
+            logging.info("Revision %d has already been packaged.",
+                         current_revision)
 
     def get_revisions(self):
         """Returns RevisionPackager objects for each packaged revision"""
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)