[Checkins] SVN: z3c.vcsync/trunk/src/z3c/vcsync/ Start the
implementation of found support. When a conflict occurs,
Martijn Faassen
faassen at infrae.com
Wed Apr 23 10:20:14 EDT 2008
Log message for revision 85646:
Start the implementation of found support. When a conflict occurs,
the other side of the conflict is stored in a special 'found' part of the
repository.
Changed:
U z3c.vcsync/trunk/src/z3c/vcsync/README.txt
U z3c.vcsync/trunk/src/z3c/vcsync/svn.py
-=-
Modified: z3c.vcsync/trunk/src/z3c/vcsync/README.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2008-04-23 14:19:23 UTC (rev 85645)
+++ z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2008-04-23 14:20:14 UTC (rev 85646)
@@ -393,11 +393,13 @@
>>> current_synchronizer = s2
>>> data2['bar'].payload = 250
-Let's synchronize the second tree first::
+Let's synchronize the second tree first. This won't generate a
+conflict yet by itself, but sets up for it::
>>> info = s2.sync("synchronize")
-Now we'll synchronize the first tree::
+Now we'll synchronize the first tree. This will generate a conflict, as
+we saved a different value from the second tree::
>>> current_synchronizer = s
>>> info = s.sync("synchronize")
@@ -411,13 +413,30 @@
When we synchronize from the second tree again, we will see the
resolved value appear as well::
- >>> current_synchronizer = s
+ >>> current_synchronizer = s2
>>> info = s2.sync("synchronize")
>>> data2['bar'].payload
200
+The other version of the conflicting object is not gone. It is stored
+under a special ``found`` directory. We'll synchronize this as well::
+
+ >>> found_data = Container()
+ >>> found_data.__name__ = 'found'
+ >>> found_state = TestState(found_data)
+ >>> found_s = Synchronizer(checkout, found_state)
+ >>> current_synchronizer = found_s
+ >>> info = found_s.sync("synchronize")
+
+We see the conflicting value that was stored by the second tree in
+here::
+
+ >>> found_data['root']['bar'].payload
+ 250
+
Conflicts in subdirectories should also be resolved properly::
+ >>> current_synchronizer = s
>>> data['sub']['qux'].payload = 35
>>> current_synchronizer = s2
>>> data2['sub']['qux'].payload = 36
@@ -430,3 +449,11 @@
>>> info = s2.sync("Synchronize")
>>> data2['sub']['qux'].payload
35
+
+The found version in this case will reside in the same subdirectory,
+``sub``::
+
+ >>> current_synchronizer = found_s
+ >>> info = found_s.sync("Synchronize")
+ >>> found_data['root']['sub']['qux'].payload
+ 36
Modified: z3c.vcsync/trunk/src/z3c/vcsync/svn.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/svn.py 2008-04-23 14:19:23 UTC (rev 85645)
+++ z3c.vcsync/trunk/src/z3c/vcsync/svn.py 2008-04-23 14:20:14 UTC (rev 85646)
@@ -39,7 +39,7 @@
self._updated_revision_nr = None
def resolve(self):
- _resolve_helper(self.path)
+ self._resolve_helper(self.path)
def commit(self, message):
revision_nr = self.path.commit(message)
@@ -57,7 +57,20 @@
def revision_nr(self):
return self._revision_nr
-
+
+ def _found(self, path, content):
+ """Store conflicting/lost content in found directory.
+
+ path - the path in the original tree. This is translated to
+ a found path with the same structure.
+ content - the file content
+ """
+ found = self.path.ensure('found', dir=True)
+ rel_path = path.relto(self.path)
+ save_path = found.join(*rel_path.split(path.sep))
+ save_path.ensure()
+ save_path.write(content)
+
def _update_files(self, revision_nr):
"""Go through svn log and update self._files and self._removed.
"""
@@ -102,29 +115,33 @@
files.add(path)
return files, removed
-def _resolve_helper(path):
- for p in path.listdir():
- if not p.check(dir=True):
- continue
- try:
- for conflict in p.status().conflict:
- mine, revs = conflict_info(conflict)
- conflict.write(mine.read())
- conflict._svn('resolved')
- # XXX This is a horrible hack to skip status of R. This
- # is not supported by Py 0.9.0, and raises a NotImplementedError.
- # This has been fixed on the trunk of Py.
- # When we upgrade to a new release of Py this can go away
- except NotImplementedError:
- pass
- _resolve_helper(p)
+ def _resolve_helper(self, path):
+ for p in path.listdir():
+ if not p.check(dir=True):
+ continue
+ try:
+ for conflict in p.status().conflict:
+ mine, other = conflict_info(conflict)
+ conflict.write(mine.read())
+ self._found(conflict, other.read())
+ conflict._svn('resolved')
+ # XXX This is a horrible hack to skip status of R. This
+ # is not supported by Py 0.9.0, and raises a NotImplementedError.
+ # This has been fixed on the trunk of Py.
+ # When we upgrade to a new release of Py this can go away
+ except NotImplementedError:
+ pass
+ self._resolve_helper(p)
def conflict_info(conflict):
path = conflict.dirpath()
name = conflict.basename
mine = path.join(name + '.mine')
name_pattern = name + '.r'
- revs = {}
+ revs = []
for rev in path.listdir(name_pattern + '*'):
- revs[int(rev.basename[len(name_pattern):])] = rev
- return mine, revs
+ revs.append((int(rev.basename[len(name_pattern):]), rev))
+ # find the most recent rev
+ rev_nr, other = sorted(revs)[-1]
+ return mine, other
+
More information about the Checkins
mailing list