changeset 190:e83db4482aab

Add runtreepkg.py command line option --no-svn-update to inhibit updates of the working copies. This can be useful if e.g. the svn server is down. Adapt the test cases.
author Bernhard Herzog <bh@intevation.de>
date Wed, 30 Jul 2008 19:00:31 +0000
parents 44efabf551e0
children 94fb3f3ab58b
files bin/runtreepkg.py test/test_packager.py treepkg/packager.py
diffstat 3 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/bin/runtreepkg.py	Tue Jul 08 15:39:34 2008 +0000
+++ b/bin/runtreepkg.py	Wed Jul 30 19:00:31 2008 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/python2.4
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2008 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
 #
@@ -36,6 +36,9 @@
     parser.add_option("--revision",
                       help=("SVN revision to update to before attempting"
                             " to package."))
+    parser.add_option("--no-svn-update", action="store_true",
+                      help=("Do not update the SVN workingcopy before"
+                            " attempting to package."))
     return parser.parse_args()
 
 def main():
@@ -59,6 +62,7 @@
         group = PackagerGroup([create_package_track(**opts)
                                for opts in packager_opts],
                               revision=options.revision,
+                              do_svn_update=not options.no_svn_update,
                               **treepkg_opts)
         if options.once:
             group.check_package_tracks()
--- a/test/test_packager.py	Tue Jul 08 15:39:34 2008 +0000
+++ b/test/test_packager.py	Wed Jul 30 19:00:31 2008 +0000
@@ -187,7 +187,7 @@
         self.do_stop = do_stop
         self.instructions_file = instructions_file
 
-    def package_if_updated(self, revision):
+    def package_if_updated(self, revision, do_svn_update=True):
         if self.do_stop:
             writefile(self.instructions_file, "stop")
         if self.do_package:
--- a/treepkg/packager.py	Tue Jul 08 15:39:34 2008 +0000
+++ b/treepkg/packager.py	Wed Jul 30 19:00:31 2008 +0000
@@ -437,9 +437,13 @@
         env["DEBEMAIL"] = self.deb_email
         return env
 
-    def package_if_updated(self, revision=None):
-        """Checks if the checkout changed and returns a new packager if so"""
-        self.update_checkout(revision=revision)
+    def package_if_updated(self, revision=None, do_svn_update=True):
+        """Returns a new packager if the working copy has not been packaged yet.
+        If do_svn_update is true -- the default -- update the working
+        copy to the the revision specified with the revision parameter
+        or if revision is None, the latest revision in the repository."""
+        if do_svn_update:
+            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():
@@ -516,10 +520,11 @@
 class PackagerGroup(object):
 
     def __init__(self, package_tracks, check_interval, revision=None,
-                 instructions_file=None):
+                 instructions_file=None, do_svn_update=True):
         self.package_tracks = package_tracks
         self.check_interval = check_interval
         self.revision = revision
+        self.do_svn_update = do_svn_update
         self.instructions_file = instructions_file
         self.instructions_file_removed = False
         self.sort_tracks()
@@ -596,7 +601,8 @@
             repeat = False
             for track in self.package_tracks:
                 try:
-                    packager = track.package_if_updated(revision=self.revision)
+                    packager = track.package_if_updated(revision=self.revision,
+                                              do_svn_update=self.do_svn_update)
                     if packager:
                         packager.package()
                         repeat = self.install_dependencies(track, packager)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)