[Checkins] SVN: z3c.vcsync/trunk/ Fix a few subtleties with SVN synchronization.

Martijn Faassen faassen at infrae.com
Thu Nov 15 21:12:12 EST 2007


Log message for revision 81871:
  Fix a few subtleties with SVN synchronization.
  

Changed:
  U   z3c.vcsync/trunk/CHANGES.txt
  U   z3c.vcsync/trunk/src/z3c/vcsync/vc.py

-=-
Modified: z3c.vcsync/trunk/CHANGES.txt
===================================================================
--- z3c.vcsync/trunk/CHANGES.txt	2007-11-16 02:09:47 UTC (rev 81870)
+++ z3c.vcsync/trunk/CHANGES.txt	2007-11-16 02:12:12 UTC (rev 81871)
@@ -4,8 +4,21 @@
 0.8.2 (unreleased)
 -----------------
 
-* ...
+Bugs fixed
+~~~~~~~~~~
 
+* In some cases a containing directory is referenced which does not
+  exist anymore when removing files. In this case we do not need to
+  remove the file anymore, as the directory itself is gone.
+
+* SVN doesn't actually remove directories, just mark them for
+  removal. This could confuse the system during synchronization:
+  removed directories might reappear again as they were still on the
+  filesystem during loading. Make sure now that any directories marked
+  for removal are also properly removed in the filesystem before load
+  starts, but after up (as rm-ing a directory marked for removal
+  before svn up will actually re-add this directory!).
+
 0.8.1 (2007-11-07)
 ------------------
 

Modified: z3c.vcsync/trunk/src/z3c/vcsync/vc.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/vc.py	2007-11-16 02:09:47 UTC (rev 81870)
+++ z3c.vcsync/trunk/src/z3c/vcsync/vc.py	2007-11-16 02:12:12 UTC (rev 81871)
@@ -1,4 +1,5 @@
 import os
+import py
 from datetime import datetime
 
 from zope.interface import Interface
@@ -71,11 +72,19 @@
     def __init__(self, checkout, state):
         self.checkout = checkout
         self.state = state
+        self._to_remove = []
 
     def sync(self, dt, message=''):
         self.save(dt)
         self.checkout.up()
         self.checkout.resolve()
+        # now after doing an up, remove dirs that can be removed
+        # it is not safe to do this during safe, as an 'svn up' will
+        # then recreate the directories again. We do want them
+        # well and gone though, as we don't want them to reappear in
+        # the ZODB when we do a load.
+        for to_remove in self._to_remove:
+            py.path.local(to_remove).remove(rec=True)
         self.load(dt)
         self.checkout.commit(message)
 
@@ -92,8 +101,14 @@
             if potential_dir_path.check():
                 # the directory exists, so remove it
                 potential_dir_path.remove()
+                # this only marks the directory for vc deletion, so let's
+                # truly get rid of it later
+                self._to_remove.append(potential_dir_path.strpath)
             else:
                 # there is no directory, so it must be a file to remove
+                # the container might not exist for whatever reason
+                if not container_dir_path.check():
+                    continue
                 # find the file and remove it
                 file_paths = list(container_dir_path.listdir(
                     str('%s.*' % name)))



More information about the Checkins mailing list