You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by tr...@apache.org on 2017/12/30 03:37:31 UTC
svn commit: r1819565 -
/subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py
Author: troycurtisjr
Date: Sat Dec 30 03:37:31 2017
New Revision: 1819565
URL: http://svn.apache.org/viewvc?rev=1819565&view=rev
Log:
On branch swig-py3: Clarify move detection logic in swig trac tests.
* subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py
(get_changes): Clarify the move detection logic by adding a few comments and
replacing the odd index/offset based loop with one based on enumerate.
Suggested By: danielsh
Modified:
subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py
Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py?rev=1819565&r1=1819564&r2=1819565&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/svn_fs.py Sat Dec 30 03:37:31 2017
@@ -392,6 +392,7 @@ class SubversionChangeset(Changeset):
repos.svn_repos_replay(root, e_ptr, e_baton)
idx = 0
+ # Variables to record copy/deletes for later move detection
copies, deletions = {}, {}
changes = []
for path, change in list(editor.changes.items()):
@@ -409,10 +410,12 @@ class SubversionChangeset(Changeset):
action = ''
if change.action == repos.CHANGE_ACTION_DELETE:
action = Changeset.DELETE
+ # Save off the index within changes of this deletion
deletions[change.base_path] = idx
elif change.added:
if change.base_path and change.base_rev:
action = Changeset.COPY
+ # Save off the index within changes of this copy
copies[change.base_path] = idx
else:
action = Changeset.ADD
@@ -423,18 +426,19 @@ class SubversionChangeset(Changeset):
changes.append([path, kind, action, base_path, change.base_rev])
idx += 1
- moves = []
+ # Detect moves by checking for copies whose source was deleted in this
+ # change set.
+ moves = set()
for k,v in list(copies.items()):
if k in deletions:
changes[v][2] = Changeset.MOVE
- moves.append(deletions[k])
- offset = 0
- for i in sorted(moves):
- del changes[i - offset]
- offset += 1
+ # Record the index of the now redundant delete action.
+ moves.add(deletions[k])
- for change in changes:
- yield tuple(change)
+ for i, change in enumerate(changes):
+ # Do not return the 'delete' changes that were part of moves.
+ if i not in moves:
+ yield tuple(change)
def _get_prop(self, name):
return fs.revision_prop(self.fs_ptr, self.rev, name)