You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/02/14 00:08:46 UTC
[6/6] git commit: [#5810] standardize slashes in tree_paths
Updated Branches:
refs/heads/db/5810 5388f06ca -> d489126c0 (forced update)
[#5810] standardize slashes in tree_paths
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d489126c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d489126c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d489126c
Branch: refs/heads/db/5810
Commit: d489126c0aaccacc839a2ad3c0dd61cce5d6b881
Parents: 4e69f82
Author: Dave Brondsema <db...@geek.net>
Authored: Tue Feb 12 23:16:59 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Wed Feb 13 23:08:31 2013 +0000
----------------------------------------------------------------------
ForgeSVN/forgesvn/model/svn.py | 4 +-
.../forgesvn/tests/model/test_svnimplementation.py | 55 +++++++++++++++
2 files changed, 57 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d489126c/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 64a36ca..1d6a815 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -396,7 +396,7 @@ class SVNImplementation(M.RepositoryImplementation):
def compute_tree_new(self, commit, tree_path='/'):
from allura.model import repo as RM
- tree_path = tree_path[:-1]
+ tree_path = '/' + tree_path.strip('/') # always leading slash, never trailing
tree_id = self._tree_oid(commit._id, tree_path)
tree = RM.Tree.query.get(_id=tree_id)
if tree:
@@ -587,7 +587,7 @@ class SVNImplementation(M.RepositoryImplementation):
single common parent path (i.e., you are only asking for
a subset of the nodes of a single tree, one level deep).
'''
- tree_path = os.path.commonprefix(paths).strip('/')
+ tree_path = '/' + os.path.commonprefix(paths).strip('/') # always leading slash, never trailing
rev = self._revision(commit._id)
try:
infos = self._svn.info2(
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d489126c/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
new file mode 100644
index 0000000..3a5ae5d
--- /dev/null
+++ b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
@@ -0,0 +1,55 @@
+from mock import Mock, MagicMock, patch
+import pysvn
+from nose.tools import assert_equal
+
+from allura.model.repo import Commit
+from forgesvn.model.svn import Repository, SVNImplementation
+
+
+class TestSVNImplementation(object):
+
+ def test_compute_tree_new(self):
+ self._test_compute_tree_new('/trunk/foo/')
+ self._test_compute_tree_new('/trunk/foo')
+ self._test_compute_tree_new('trunk/foo/')
+ self._test_compute_tree_new('trunk/foo')
+
+ @patch('allura.model.repo.LastCommitDoc.m.update_partial')
+ @patch('allura.model.repo.TreesDoc.m.update_partial')
+ @patch('allura.model.repo.Tree.upsert')
+ @patch('allura.model.repo.Tree.query.get')
+ def _test_compute_tree_new(self, path, tree_get, tree_upsert, treesdoc_partial, lcd_partial):
+ repo = Mock(fs_path='/tmp/')
+ repo.name = 'code'
+ impl = SVNImplementation(repo)
+ impl._svn.info2 = Mock()
+ impl._svn.info2.return_value = [('foo', Mock())]
+ tree_get.return_value = None # no existing tree
+ commit = Commit()
+ commit._id = '5057636b9c1040636b81e4b1:6'
+ tree_upsert.return_value = (Mock(), True)
+
+ tree_id = impl.compute_tree_new(commit, path)
+
+ assert_equal(impl._svn.info2.call_args[0][0], 'file:///tmp/code/trunk/foo')
+ treesdoc_partial.assert_called()
+ lcd_partial.assert_called()
+
+
+ def test_last_commit_ids(self):
+ self._test_last_commit_ids('/trunk/foo/')
+ self._test_last_commit_ids('/trunk/foo')
+ self._test_last_commit_ids('trunk/foo/')
+ self._test_last_commit_ids('trunk/foo')
+
+ def _test_last_commit_ids(self, path):
+ repo = Mock(fs_path='/tmp/')
+ repo.name = 'code'
+ impl = SVNImplementation(repo)
+ impl._svn.info2 = Mock()
+ impl._svn.info2.return_value = [('foo', Mock())]
+ commit = Commit()
+ commit._id = '5057636b9c1040636b81e4b1:6'
+ tree_id = impl.last_commit_ids(commit, [path])
+
+ assert_equal(impl._svn.info2.call_args[0][0], 'file:///tmp/code/trunk/foo')