[Checkins] SVN: z3c.vcsync/trunk/src/z3c/vcsync/ Work with the new
interface.
Martijn Faassen
faassen at infrae.com
Thu Jul 5 14:48:35 EDT 2007
Log message for revision 77475:
Work with the new interface.
Changed:
U z3c.vcsync/trunk/src/z3c/vcsync/README.txt
U z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
U z3c.vcsync/trunk/src/z3c/vcsync/tests.py
U z3c.vcsync/trunk/src/z3c/vcsync/vc.py
-=-
Modified: z3c.vcsync/trunk/src/z3c/vcsync/README.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2007-07-05 18:20:04 UTC (rev 77474)
+++ z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2007-07-05 18:48:35 UTC (rev 77475)
@@ -406,16 +406,19 @@
>>> grok.grok_component('ContainerFactory', ContainerFactory)
True
-We need to maintain a list of everything modified, added or deleted by
-the update operation. Normally this information is extracted from the
-version control system, but for the purposes of this test we maintain
-it manually. In this case, everything is added::
+We need to maintain a list of everything modified or added, and a list
+of everything deleted by the update operation. Normally this
+information is extracted from the version control system, but for the
+purposes of this test we maintain it manually. In this case,
+everything is added so appears in the files list::
- >>> checkout._added = [root.join('foo.test'), root.join('hoi.test'),
+ >>> checkout._files = [root.join('foo.test'), root.join('hoi.test'),
... root.join('sub'), root.join('sub', 'qux.test')]
- >>> checkout._deleted = []
- >>> checkout._modified = []
+Nothing was removed::
+
+ >>> checkout._removed = []
+
Let's load up the contents from the filesystem now, into a new container::
>>> container2 = Container()
@@ -476,9 +479,8 @@
We maintain the lists of things changed::
- >>> checkout._added = []
- >>> checkout._deleted = []
- >>> checkout._modified = [hoi_path]
+ >>> checkout._files = [hoi_path]
+ >>> checkout._removed = []
We will reload the checkout into Python objects::
@@ -503,9 +505,8 @@
We maintain the lists of things changed::
- >>> checkout._added = [hallo]
- >>> checkout._deleted = []
- >>> checkout._modified = []
+ >>> checkout._files = [hallo]
+ >>> checkout._removed = []
We will reload the checkout into Python objects again::
@@ -529,9 +530,8 @@
We maintain the lists of things changed::
- >>> checkout._added = []
- >>> checkout._deleted = [hallo]
- >>> checkout._modified = []
+ >>> checkout._files = []
+ >>> checkout._removed = [hallo]
We will reload the checkout into Python objects::
@@ -559,9 +559,8 @@
We maintain the lists of things changed::
- >>> checkout._added = [newdir_path, newdir_path.join('newfile.test')]
- >>> checkout._deleted = []
- >>> checkout._modified = []
+ >>> checkout._files = [newdir_path, newdir_path.join('newfile.test')]
+ >>> checkout._removed = []
Reloading this will cause a new container to exist::
@@ -586,9 +585,8 @@
We maintain the lists of things changed::
- >>> checkout._added = []
- >>> checkout._deleted = [newdir_path, newdir_path.join('newfile.test')]
- >>> checkout._modified = []
+ >>> checkout._files = []
+ >>> checkout._removed = [newdir_path, newdir_path.join('newfile.test')]
And reload the data::
@@ -615,9 +613,8 @@
We maintain the lists of things changed::
- >>> checkout._added = [hoi_path2, hoi_path2.join('some.test')]
- >>> checkout._deleted = [hoi_path]
- >>> checkout._modified = []
+ >>> checkout._files = [hoi_path2, hoi_path2.join('some.test')]
+ >>> checkout._removed = [hoi_path]
>>> checkout.up()
@@ -645,9 +642,8 @@
We maintain the lists of things changed::
- >>> checkout._added = [hoi_path]
- >>> checkout._deleted = [hoi_path2.join('some.test'), hoi_path2]
- >>> checkout._modified = []
+ >>> checkout._files = [hoi_path]
+ >>> checkout._removed = [hoi_path2.join('some.test'), hoi_path2]
Reloading this will cause a new item to be there instead of the
container::
@@ -676,9 +672,8 @@
We maintain the lists of things changed::
- >>> checkout._added = [alpha_path]
- >>> checkout._deleted = []
- >>> checkout._modified = []
+ >>> checkout._files = [alpha_path]
+ >>> checkout._removed = []
Now we'll synchronize with the memory structure::
Modified: z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py 2007-07-05 18:20:04 UTC (rev 77474)
+++ z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py 2007-07-05 18:48:35 UTC (rev 77475)
@@ -78,13 +78,13 @@
def files(dt):
"""Files added/modified in state since dt.
- Returns paths to files that were added/modified.
+ Returns paths to files that were added/modified since dt.
"""
def removed(dt):
"""Files removed in state since dt.
- Returns paths to files that were removed.
+ Returns filesystem (py) paths to files that were removed.
"""
class IState(Interface):
@@ -93,22 +93,23 @@
root = Attribute('The root container')
def objects(dt):
- """Objects present in state.
+ """Objects modified/added in state since dt.
- Not all objects have to be returned. At a minimum, only those
- objects that have been modified or added since dt need to
- be returned.
+ Ideally, only those objects that have been modified or added
+ since dt should be returned. Returning more objects (as long
+ as they exist) is safe, however, though less efficient.
"""
def removed(dt):
- """Paths removed.
+ """Paths removed since dt.
The path is a path from the state root object to the actual
object that was removed. It is therefore not the same as the
physically locatable path.
-
- Any path that has been removed since dt should be returned. This
- path might have been added again later, so it is safe to return
- paths of objects returned by the 'objects' method.
+
+ Ideally, only those paths that have been removed since dt
+ should be returned. It is safe to return paths that were added
+ again later, so it is safe to return paths of objects returned
+ by the 'objects' method.
"""
Modified: z3c.vcsync/trunk/src/z3c/vcsync/tests.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/tests.py 2007-07-05 18:20:04 UTC (rev 77474)
+++ z3c.vcsync/trunk/src/z3c/vcsync/tests.py 2007-07-05 18:48:35 UTC (rev 77475)
@@ -20,9 +20,8 @@
def __init__(self, path):
self.path = path
self.update_function = None
- self._added = []
- self._deleted = []
- self._modified = []
+ self._files = []
+ self._removed = []
def up(self):
# call update_function which will modify the checkout as might
@@ -36,14 +35,11 @@
def commit(self, message):
pass
- def added(self):
- return self._added
+ def files(self, dt):
+ return self._files
- def deleted(self):
- return self._deleted
-
- def modified(self):
- return self._modified
+ def removed(self, dt):
+ return self._removed
class TestState(object):
grok.implements(IState)
Modified: z3c.vcsync/trunk/src/z3c/vcsync/vc.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/vc.py 2007-07-05 18:20:04 UTC (rev 77474)
+++ z3c.vcsync/trunk/src/z3c/vcsync/vc.py 2007-07-05 18:48:35 UTC (rev 77475)
@@ -104,26 +104,27 @@
self._get_container_path(root, obj))
def load(self, dt):
+ # remove all objects that have been removed in the checkout
root = self.state.root
-
- for deleted_path in self.checkout.deleted():
- obj = resolve(root, self.checkout.path, deleted_path)
+ # sort to ensure that containers are deleted before items in them
+ removed_paths = self.checkout.removed(dt)
+ removed_paths.sort()
+ for removed_path in removed_paths:
+ obj = resolve(root, self.checkout.path, removed_path)
if obj is not None:
del obj.__parent__[obj.__name__]
- added_paths = self.checkout.added()
+ # now modify/add all objects that have been modified/added in the
+ # checkout
+ file_paths = self.checkout.files(dt)
# to ensure that containers are created before items we sort them
- sorted(added_paths)
- for added_path in added_paths:
- obj = resolve_container(root, self.checkout.path, added_path)
- factory = getUtility(IVcFactory, name=added_path.ext)
- obj[added_path.purebasename] = factory(self, added_path)
- for modified_path in self.checkout.modified():
- obj = resolve(root, self.checkout.path, modified_path)
- factory = getUtility(IVcFactory, name=modified_path.ext)
- container = obj.__parent__
- name = obj.__name__
- del container[name]
- container[name] = factory(self, modified_path)
+ file_paths.sort()
+ for file_path in file_paths:
+ container = resolve_container(root, self.checkout.path, file_path)
+ factory = getUtility(IVcFactory, name=file_path.ext)
+ name = file_path.purebasename
+ if name in container:
+ del container[name]
+ container[name] = factory(self, file_path)
def _get_container_path(self, root, obj):
steps = []
More information about the Checkins
mailing list