[Zope3-checkins] CVS: Zope3/src/zope/fssync - fsmerger.py:1.10
Guido van Rossum
guido@python.org
Thu, 5 Jun 2003 10:41:56 -0400
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv7728
Modified Files:
fsmerger.py
Log Message:
Another refactoring of the code that gets rid of the Original, Extra
and Annotations stuff when an object is removed.
=== Zope3/src/zope/fssync/fsmerger.py 1.9 => 1.10 ===
--- Zope3/src/zope/fssync/fsmerger.py:1.9 Wed Jun 4 07:11:29 2003
+++ Zope3/src/zope/fssync/fsmerger.py Thu Jun 5 10:41:55 2003
@@ -56,32 +56,38 @@
self.reporter("XXX %s" % local)
self.merge_extra(local, remote)
self.merge_annotations(local, remote)
+ if not exists(local) and not self.metadata.getentry(local):
+ self.remove_special(local, "Extra")
+ self.remove_special(local, "Annotations")
+ self.remove_special(local, "Original")
def merge_extra(self, local, remote):
"""Helper to merge the Extra trees."""
lextra = fsutil.getextra(local)
rextra = fsutil.getextra(remote)
self.merge_dirs(lextra, rextra)
- if not exists(local):
- self.remove_special(local, "Extra")
def merge_annotations(self, local, remote):
"""Helper to merge the Anotations trees."""
lannotations = fsutil.getannotations(local)
rannotations = fsutil.getannotations(remote)
self.merge_dirs(lannotations, rannotations)
- if not exists(local):
- self.remove_special(local, "Annotations")
def remove_special(self, local, what):
- """Helper to remove an Extra or Annotations tree."""
- lextra = fsutil.getextra(local)
- if isdir(lextra):
- shutil.rmtree(lextra)
- try:
- os.rmdir(join(local, "@@Zope", "Extra"))
- except os.error:
- pass
+ """Helper to remove an Original, Extra or Annotations file/tree."""
+ head, tail = fsutil.split(local)
+ dir = join(head, "@@Zope", what)
+ target = join(dir, tail)
+ if exists(target):
+ if isdir(target):
+ shutil.rmtree(target)
+ else:
+ os.remove(target)
+ if isdir(dir):
+ try:
+ os.rmdir(dir)
+ except os.error:
+ pass
def merge_files(self, local, remote):
"""Merge remote file into local file."""