changeset 229:653a45adda50

Prepare for svn managed debian rules directories. So far, the directory names used for a particular revision were of the form <revision>-1 . Now the second number (which was always 1 up to now) will become the svn revision of the debian rules directory. As a first step towards that, the packager classes now support numbers other than 1 as the second number in the package directory name. Update the tests accordingly.
author Bernhard Herzog <bh@intevation.de>
date Tue, 13 Jan 2009 13:48:59 +0000
parents d2ddd037ddaf
children e387b879fd38
files test/test_packager.py treepkg/packager.py
diffstat 2 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Fri Jan 09 21:13:51 2009 +0000
+++ b/test/test_packager.py	Tue Jan 13 13:48:59 2009 +0000
@@ -192,7 +192,7 @@
         if self.do_stop:
             writefile(self.instructions_file, "stop")
         if self.do_package:
-            return StoppingPackager(self, 1)
+            return StoppingPackager(self, 1, 0)
         else:
             return None
 
@@ -252,16 +252,17 @@
         # of revisions
         trackdir = self.create_files("track",
                                      [("pkg",
-                                       [("704195-1",
+                                       [("704195-0",
                                          [("status", ""),
                                           ("src", []),
                                           ("binary", [])]),
-                                        ("702432-1",
+                                        ("702432-2",
                                          [("status", ""),
                                           ("src", []),
                                           ("binary", [])])])])
         track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
-        self.assertEquals(track.get_revision_numbers(), [702432, 704195])
+        self.assertEquals(track.get_revision_numbers(),
+                          [(702432, 2), (704195, 0)])
 
 
 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
@@ -269,7 +270,7 @@
     def test_list_source_files(self):
         trackdir = self.create_files("track",
                                      [("pkg",
-                                       [("704195-1",
+                                       [("704195-31",
                                          [("status",
                                            ("TreePackagerStatus 0.0\n"
                                             "status: binary_package_created\n"
@@ -284,8 +285,8 @@
                                           ("src", []),
                                           ("binary", [])])])])
         track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
-        revpkg = RevisionPackager(track, 704195)
-        srcdir = os.path.join(trackdir, "pkg", "704195-1", "src")
+        revpkg = RevisionPackager(track, 704195, 31)
+        srcdir = os.path.join(trackdir, "pkg", "704195-31", "src")
         self.assertEquals(revpkg.list_source_files(),
                           [os.path.join(srcdir, filename)
                            for filename in ["test_1.0-1.diff.gz",
@@ -310,7 +311,7 @@
                                           ("src", []),
                                           ("binary", [])])])])
         track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
-        revpkg = RevisionPackager(track, 704195)
+        revpkg = RevisionPackager(track, 704195, 1)
         bindir = os.path.join(trackdir, "pkg", "704195-1", "binary")
         self.assertEquals(revpkg.list_binary_files(),
                           [os.path.join(bindir, filename)
--- a/treepkg/packager.py	Fri Jan 09 21:13:51 2009 +0000
+++ b/treepkg/packager.py	Tue Jan 13 13:48:59 2009 +0000
@@ -230,10 +230,12 @@
     source_packager_cls = SourcePackager
     binary_packager_cls = BinaryPackager
 
-    def __init__(self, track, revision):
+    def __init__(self, track, revision, rules_revision):
         self.track = track
         self.revision = revision
-        self.base_dir = self.track.pkg_dir_for_revision(self.revision, 1)
+        self.rules_revision = rules_revision
+        self.base_dir = self.track.pkg_dir_for_revision(self.revision,
+                                                        rules_revision)
         self.status = status.RevisionStatus(os.path.join(self.base_dir,
                                                          "status"))
 
@@ -331,9 +333,9 @@
         self.do_build = do_build
         self.handle_dependencies = handle_dependencies
         self.dependencies = None
-        self.pkg_dir_template = "%(revision)d-%(increment)d"
-        self.pkg_dir_regex \
-                   = re.compile(r"(?P<revision>[0-9]+)-(?P<increment>[0-9]+)$")
+        self.pkg_dir_template = "%(revision)d-%(rules_revision)d"
+        self.pkg_dir_regex = re.compile(r"(?P<revision>[0-9]+)"
+                                        r"-(?P<rules_revision>[0-9]+)$")
         repo = SvnRepository(svn_url, self.svn_external_subdirs)
         self.working_copy = SvnWorkingCopy(repo, self.checkout_dir,
                                            logger=logging)
@@ -383,7 +385,7 @@
         self.determine_dependencies()
         return self.dependencies[1]
 
-    def pkg_dir_for_revision(self, revision, increment):
+    def pkg_dir_for_revision(self, revision, rules_revision):
         return os.path.join(self.pkg_dir,
                             self.pkg_dir_template % locals())
 
@@ -397,7 +399,8 @@
             for filename in os.listdir(self.pkg_dir):
                 match = self.pkg_dir_regex.match(filename)
                 if match:
-                    revisions.append(int(match.group("revision")))
+                    revisions.append((int(match.group("revision")),
+                                      int(match.group("rules_revision"))))
         revisions.sort()
         return revisions
 
@@ -436,18 +439,18 @@
             self.update_checkout(revision=revision)
         current_revision = self.last_changed_revision()
         logging.info("New revision is %d", current_revision)
-        if current_revision not in self.get_revision_numbers():
+        if (current_revision, 1) 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)
+            return self.revision_packager_cls(self, current_revision, 1)
         else:
             logging.info("Revision %d has already been packaged.",
                          current_revision)
 
     def get_revisions(self):
         """Returns RevisionPackager objects for each packaged revision"""
-        return [self.revision_packager_cls(self, revision)
-                for revision in self.get_revision_numbers()]
+        return [self.revision_packager_cls(self, revision, rules_revision)
+                for revision, rules_revision in self.get_revision_numbers()]
 
     def sign_file(self, filename):
         """Signs a file using the debian.sign_file function.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)