[Checkins] SVN: zope.app.fssync/branches/jim-hack/src/zope/app/fssync/ Fixed merge to work better with directories.
Amos Latteier
amos at latteier.com
Tue Feb 24 11:35:46 EST 2009
Log message for revision 97213:
Fixed merge to work better with directories.
Changed:
U zope.app.fssync/branches/jim-hack/src/zope/app/fssync/fssync.py
U zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.py
U zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.txt
-=-
Modified: zope.app.fssync/branches/jim-hack/src/zope/app/fssync/fssync.py
===================================================================
--- zope.app.fssync/branches/jim-hack/src/zope/app/fssync/fssync.py 2009-02-24 14:42:26 UTC (rev 97212)
+++ zope.app.fssync/branches/jim-hack/src/zope/app/fssync/fssync.py 2009-02-24 16:35:45 UTC (rev 97213)
@@ -32,6 +32,7 @@
from StringIO import StringIO
+import os.path
from os.path import exists, isfile, isdir
from os.path import dirname, basename, split, join
from os.path import realpath, normcase, normpath
@@ -492,8 +493,9 @@
print 'Cannot merge from %s to %s' % (source_entry[u'id'],
target_entry[u'id'])
return
-
- zope.app.fssync.merge.merge(source, target, self)
+
+ zope.app.fssync.merge.merge(os.path.abspath(source),
+ os.path.abspath(target), self)
print 'All done.'
Modified: zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.py
===================================================================
--- zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.py 2009-02-24 14:42:26 UTC (rev 97212)
+++ zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.py 2009-02-24 16:35:45 UTC (rev 97213)
@@ -19,6 +19,7 @@
"""
import os
import os.path
+import shutil
import zope.fssync.fsutil
import zope.fssync.copier
@@ -29,6 +30,15 @@
entries in the destination checkout, since they should already be
present.
"""
+
+ def copy(self, source, target, children=True):
+ if os.path.isdir(source):
+ shutil.copymode(source, target)
+ self.addEntry(source, target)
+ else:
+ shutil.copy(source, target)
+ self.addEntry(source, target)
+
def _copyspecials(self, source, target, getwhat):
src = getwhat(source)
if os.path.isdir(src):
@@ -112,7 +122,7 @@
for root, dirs, files in os.walk(source):
if '@@Zope' in dirs:
dirs.remove('@@Zope')
- for filename in (files + ['']):
+ for filename in ([''] + files):
source_path = os.path.join(root, filename)
if metadata.getentry(source_path):
directory = root[len(source) + 1:]
Modified: zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.txt
===================================================================
--- zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.txt 2009-02-24 14:42:26 UTC (rev 97212)
+++ zope.app.fssync/branches/jim-hack/src/zope/app/fssync/merge.txt 2009-02-24 16:35:45 UTC (rev 97213)
@@ -83,6 +83,13 @@
>>> zsync.add(localfile3)
A .../test/file3.txt
+A new directory.
+
+ >>> sitedir = os.path.join(checkoutdir, 'test', 'newfolder')
+ >>> os.mkdir(sitedir)
+ >>> zsync.add(sitedir)
+ A .../test/newfolder/
+
Here's a deletion.
>>> os.unlink(os.path.join(checkoutdir, 'test', 'file2.txt'))
@@ -104,6 +111,9 @@
U .../test/@@Zope/Extra/file3.txt/contentType
N .../test/@@Zope/Annotations/file3.txt/
U .../test/@@Zope/Annotations/file3.txt/zope.app.dublincore.ZopeDublinCore
+ U .../test/newfolder/
+ N .../test/@@Zope/Annotations/newfolder/
+ U .../test/@@Zope/Annotations/newfolder/zope.app.dublincore.ZopeDublinCore
All done.
At this point the two checkouts are not in sync.
@@ -121,6 +131,7 @@
>>> zsync.merge((checkoutdir, checkoutdir2))
M .../test/file1.txt
A .../test/file3.txt
+ A .../test/newfolder/
All done.
The status command reflects the local changes.
@@ -130,6 +141,7 @@
M .../test/file1.txt
= .../test/file2.txt
A .../test/file3.txt
+ A .../test/newfolder/
The change and the addition were picked up, but the deletion wasn't.
@@ -151,6 +163,9 @@
>>> f1.close()
>>> f2.close()
+ >>> os.path.isdir(os.path.join(checkoutdir2, 'test', 'newfolder'))
+ True
+
Let's make sure that extras were also copied over.
>>> open(os.path.join(checkoutdir2, 'test', '@@Zope', 'Extra',
More information about the Checkins
mailing list