allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/7] [#7305] Consolidate allura.model.repo into allura.model.repository
Date Mon, 14 Apr 2014 17:21:33 GMT
http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/Allura/allura/scripts/refreshrepo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/refreshrepo.py b/Allura/allura/scripts/refreshrepo.py
index c7ac08d..08f3fcc 100644
--- a/Allura/allura/scripts/refreshrepo.py
+++ b/Allura/allura/scripts/refreshrepo.py
@@ -75,26 +75,26 @@ class RefreshRepo(ScriptTask):
                         for ci_ids_chunk in chunked_list(ci_ids, 3000):
                             tree_ids.extend([
                                 tree_id for doc in
-                                M.repo.TreesDoc.m.find(
+                                M.repository.TreesDoc.m.find(
                                     {"_id": {"$in": ci_ids_chunk}},
                                     {"tree_ids": 1})
                                 for tree_id in doc.get("tree_ids", [])])
 
-                            i = M.repo.CommitDoc.m.find(
+                            i = M.repository.CommitDoc.m.find(
                                 {"_id": {"$in": ci_ids_chunk}}).count()
                             if i:
                                 log.info("Deleting %i CommitDoc docs...", i)
-                                M.repo.CommitDoc.m.remove(
+                                M.repository.CommitDoc.m.remove(
                                     {"_id": {"$in": ci_ids_chunk}})
 
                         # delete these in chunks, otherwise the query doc can
                         # exceed the max BSON size limit (16MB at the moment)
                         for tree_ids_chunk in chunked_list(tree_ids, 300000):
-                            i = M.repo.TreeDoc.m.find(
+                            i = M.repository.TreeDoc.m.find(
                                 {"_id": {"$in": tree_ids_chunk}}).count()
                             if i:
                                 log.info("Deleting %i TreeDoc docs...", i)
-                                M.repo.TreeDoc.m.remove(
+                                M.repository.TreeDoc.m.remove(
                                     {"_id": {"$in": tree_ids_chunk}})
                         del tree_ids
 
@@ -102,34 +102,34 @@ class RefreshRepo(ScriptTask):
                         # we crash, we don't lose the ability to delete those
                         for ci_ids_chunk in chunked_list(ci_ids, 3000):
                             # delete TreesDocs
-                            i = M.repo.TreesDoc.m.find(
+                            i = M.repository.TreesDoc.m.find(
                                 {"_id": {"$in": ci_ids_chunk}}).count()
                             if i:
                                 log.info("Deleting %i TreesDoc docs...", i)
-                                M.repo.TreesDoc.m.remove(
+                                M.repository.TreesDoc.m.remove(
                                     {"_id": {"$in": ci_ids_chunk}})
 
                             # delete LastCommitDocs
-                            i = M.repo.LastCommitDoc.m.find(
+                            i = M.repository.LastCommitDoc.m.find(
                                 dict(commit_ids={'$in': ci_ids_chunk})).count()
                             if i:
                                 log.info(
                                     "Deleting %i remaining LastCommitDoc docs, by repo id...", i)
-                                M.repo.LastCommitDoc.m.remove(
+                                M.repository.LastCommitDoc.m.remove(
                                     dict(commit_ids={'$in': ci_ids_chunk}))
 
-                            i = M.repo.DiffInfoDoc.m.find(
+                            i = M.repository.DiffInfoDoc.m.find(
                                 {"_id": {"$in": ci_ids_chunk}}).count()
                             if i:
                                 log.info("Deleting %i DiffInfoDoc docs...", i)
-                                M.repo.DiffInfoDoc.m.remove(
+                                M.repository.DiffInfoDoc.m.remove(
                                     {"_id": {"$in": ci_ids_chunk}})
 
-                            i = M.repo.CommitRunDoc.m.find(
+                            i = M.repository.CommitRunDoc.m.find(
                                 {"commit_ids": {"$in": ci_ids_chunk}}).count()
                             if i:
                                 log.info("Deleting %i CommitRunDoc docs...", i)
-                                M.repo.CommitRunDoc.m.remove(
+                                M.repository.CommitRunDoc.m.remove(
                                     {"commit_ids": {"$in": ci_ids_chunk}})
                         del ci_ids
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index cd019ae..9e2af07 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -65,14 +65,14 @@ class TestGitLikeTree(object):
 class RepoImplTestBase(object):
 
     def test_commit_run(self):
-        M.repo.CommitRunDoc.m.remove()
+        M.repository.CommitRunDoc.m.remove()
         commit_ids = list(self.repo.all_commit_ids())
         # simulate building up a commit run from multiple pushes
         for c_id in commit_ids:
             crb = M.repo_refresh.CommitRunBuilder([c_id])
             crb.run()
             crb.cleanup()
-        runs = M.repo.CommitRunDoc.m.find().all()
+        runs = M.repository.CommitRunDoc.m.find().all()
         self.assertEqual(len(runs), 1)
         run = runs[0]
         self.assertEqual(run.commit_ids, commit_ids)
@@ -91,7 +91,7 @@ class RepoImplTestBase(object):
         crb = M.repo_refresh.CommitRunBuilder(commit_ids)
         crb.run()
         crb.cleanup()
-        runs = M.repo.CommitRunDoc.m.find().all()
+        runs = M.repository.CommitRunDoc.m.find().all()
         self.assertEqual(len(runs), 1)
         run = runs[0]
         self.assertEqual(run.commit_ids, commit_ids)
@@ -185,7 +185,7 @@ class TestLastCommit(unittest.TestCase):
             email='test@example.com',
             date=datetime(2013, 1, 1 + len(self.repo._commits)),
         )
-        commit = M.repo.Commit(
+        commit = M.repository.Commit(
             _id=str(ObjectId()),
             message=msg,
             parent_ids=[parent._id for parent in parents],
@@ -210,7 +210,7 @@ class TestLastCommit(unittest.TestCase):
             'file1',
             'dir1/file2',
         ])
-        lcd = M.repo.LastCommit.get(commit1.tree)
+        lcd = M.repository.LastCommit.get(commit1.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, '')
@@ -224,7 +224,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
-        lcd = M.repo.LastCommit.get(commit3.tree)
+        lcd = M.repository.LastCommit.get(commit3.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
@@ -240,7 +240,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 2', ['file1', 'dir1/file1'], ['dir1/file1'], [commit1])
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file1', 'file2'], [commit2])
-        lcd = M.repo.LastCommit.get(commit3.tree)
+        lcd = M.repository.LastCommit.get(commit3.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
@@ -255,7 +255,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
-        lcd = M.repo.LastCommit.get(commit3.tree)
+        lcd = M.repository.LastCommit.get(commit3.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
@@ -270,7 +270,7 @@ class TestLastCommit(unittest.TestCase):
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file1'], [commit2])
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
-        lcd = M.repo.LastCommit.get(tree)
+        lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
@@ -287,7 +287,7 @@ class TestLastCommit(unittest.TestCase):
         commit4 = self._add_commit(
             'Commit 4', ['file1', 'dir1/file1', 'dir1/file2', 'file2'], ['file2'], [commit3])
         tree = self._build_tree(commit4, '/dir1', ['file1', 'file2'])
-        lcd = M.repo.LastCommit.get(tree)
+        lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
@@ -300,7 +300,7 @@ class TestLastCommit(unittest.TestCase):
         commit2 = self._add_commit(
             'Commit 2', ['file1', 'file2'], ['file2'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
-        lcd = M.repo.LastCommit.get(tree)
+        lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, 'dir1')
@@ -311,7 +311,7 @@ class TestLastCommit(unittest.TestCase):
         commit2 = self._add_commit(
             'Commit 2', ['file1'], ['dir1/file1'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
-        lcd = M.repo.LastCommit.get(tree)
+        lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
@@ -323,7 +323,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 2', ['file1', 'dir1/file1', 'dir1/file2'], ['dir1/file2'], [commit1])
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'], [commit2])
-        prev_lcd = M.repo.LastCommit(
+        prev_lcd = M.repository.LastCommit(
             path='dir1',
             commit_id=commit2._id,
             entries=[
@@ -337,7 +337,7 @@ class TestLastCommit(unittest.TestCase):
         )
         session(prev_lcd).flush()
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
-        lcd = M.repo.LastCommit.get(tree)
+        lcd = M.repository.LastCommit.get(tree)
         self.assertEqual(lcd._id, prev_lcd._id)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit2.message)
@@ -352,7 +352,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 3', ['file1', 'file2', 'file3'], ['file3'], [commit2])
         commit4 = self._add_commit(
             'Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2', 'file4'], [commit3])
-        prev_lcd = M.repo.LastCommit(
+        prev_lcd = M.repository.LastCommit(
             path='',
             commit_id=commit3._id,
             entries=[
@@ -368,7 +368,7 @@ class TestLastCommit(unittest.TestCase):
             ],
         )
         session(prev_lcd).flush()
-        lcd = M.repo.LastCommit.get(commit4.tree)
+        lcd = M.repository.LastCommit.get(commit4.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit4.message)
         self.assertEqual(lcd.path, '')
@@ -398,7 +398,7 @@ class TestLastCommit(unittest.TestCase):
         commit3 = self._add_commit(
             'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         with h.push_config(config, lcd_timeout=-1000):
-            lcd = M.repo.LastCommit.get(commit3.tree)
+            lcd = M.repository.LastCommit.get(commit3.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
@@ -414,7 +414,7 @@ class TestLastCommit(unittest.TestCase):
             'Commit 3', ['file1', 'dir1/file1', 'file2'], ['file2'], [commit2])
         commit2.parent_ids = [commit3._id]
         session(commit2).flush(commit2)
-        lcd = M.repo.LastCommit.get(commit3.tree)
+        lcd = M.repository.LastCommit.get(commit3.tree)
         self.assertEqual(
             self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.commit_id, commit3._id)
@@ -427,7 +427,7 @@ class TestLastCommit(unittest.TestCase):
 class TestModelCache(unittest.TestCase):
 
     def setUp(self):
-        self.cache = M.repo.ModelCache()
+        self.cache = M.repository.ModelCache()
 
     def test_normalize_query(self):
         self.assertEqual(self.cache._normalize_query(
@@ -441,94 +441,94 @@ class TestModelCache(unittest.TestCase):
         self.assertEquals(self.cache._model_query(m), 'bar')
         self.assertRaises(AttributeError, self.cache._model_query, [n])
 
-    @mock.patch.object(M.repo.Tree.query, 'get')
-    @mock.patch.object(M.repo.LastCommit.query, 'get')
+    @mock.patch.object(M.repository.Tree.query, 'get')
+    @mock.patch.object(M.repository.LastCommit.query, 'get')
     def test_get(self, lc_get, tr_get):
         tree = tr_get.return_value = mock.Mock(
             spec=['_id', 'val'], _id='foo', val='bar')
         lcd = lc_get.return_value = mock.Mock(
             spec=['_id', 'val'], _id='foo', val='qux')
 
-        val = self.cache.get(M.repo.Tree, {'_id': 'foo'})
+        val = self.cache.get(M.repository.Tree, {'_id': 'foo'})
         tr_get.assert_called_with(_id='foo')
         self.assertEqual(val, tree)
 
-        val = self.cache.get(M.repo.LastCommit, {'_id': 'foo'})
+        val = self.cache.get(M.repository.LastCommit, {'_id': 'foo'})
         lc_get.assert_called_with(_id='foo')
         self.assertEqual(val, lcd)
 
-    @mock.patch.object(M.repo.Tree.query, 'get')
+    @mock.patch.object(M.repository.Tree.query, 'get')
     def test_get_no_query(self, tr_get):
         tree1 = tr_get.return_value = mock.Mock(
             spec=['_id', 'val'], _id='foo', val='bar')
-        val = self.cache.get(M.repo.Tree, {'_id': 'foo'})
+        val = self.cache.get(M.repository.Tree, {'_id': 'foo'})
         tr_get.assert_called_once_with(_id='foo')
         self.assertEqual(val, tree1)
 
         tree2 = tr_get.return_value = mock.Mock(_id='foo', val='qux')
-        val = self.cache.get(M.repo.Tree, {'_id': 'foo'})
+        val = self.cache.get(M.repository.Tree, {'_id': 'foo'})
         tr_get.assert_called_once_with(_id='foo')
         self.assertEqual(val, tree1)
 
-    @mock.patch.object(M.repo.TreesDoc.m, 'get')
+    @mock.patch.object(M.repository.TreesDoc.m, 'get')
     def test_get_doc(self, tr_get):
         trees = tr_get.return_value = mock.Mock(
             spec=['_id', 'val'], _id='foo', val='bar')
-        val = self.cache.get(M.repo.TreesDoc, {'_id': 'foo'})
+        val = self.cache.get(M.repository.TreesDoc, {'_id': 'foo'})
         tr_get.assert_called_once_with(_id='foo')
         self.assertEqual(val, trees)
 
     def test_set(self):
         tree = mock.Mock(spec=['_id', 'test_set'], _id='foo', val='test_set')
-        self.cache.set(M.repo.Tree, {'val': 'test_set'}, tree)
+        self.cache.set(M.repository.Tree, {'val': 'test_set'}, tree)
         self.assertEqual(self.cache._query_cache,
-                         {M.repo.Tree: {(('val', 'test_set'),): 'foo'}})
+                         {M.repository.Tree: {(('val', 'test_set'),): 'foo'}})
         self.assertEqual(self.cache._instance_cache,
-                         {M.repo.Tree: {'foo': tree}})
+                         {M.repository.Tree: {'foo': tree}})
 
     @mock.patch('bson.ObjectId')
     def test_set_none_id(self, obj_id):
         obj_id.return_value = 'OBJID'
         tree = mock.Mock(spec=['_id', 'test_set'], _id=None, val='test_set')
-        self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, tree)
-        self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, tree)
-        self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
+        self.cache.set(M.repository.Tree, {'val1': 'test_set1'}, tree)
+        self.cache.set(M.repository.Tree, {'val2': 'test_set2'}, tree)
+        self.assertEqual(dict(self.cache._query_cache[M.repository.Tree]), {
             (('val1', 'test_set1'),): 'OBJID',
             (('val2', 'test_set2'),): 'OBJID',
         })
         self.assertEqual(self.cache._instance_cache,
-                         {M.repo.Tree: {'OBJID': tree}})
+                         {M.repository.Tree: {'OBJID': tree}})
         tree._id = '_id'
         self.assertEqual(
-            self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
+            self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
         self.assertEqual(
-            self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
-        self.cache.set(M.repo.Tree, {'val1': 'test_set2'}, tree)
+            self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
+        self.cache.set(M.repository.Tree, {'val1': 'test_set2'}, tree)
         self.assertEqual(
-            self.cache.get(M.repo.Tree, {'val1': 'test_set1'}), tree)
+            self.cache.get(M.repository.Tree, {'val1': 'test_set1'}), tree)
         self.assertEqual(
-            self.cache.get(M.repo.Tree, {'val2': 'test_set2'}), tree)
+            self.cache.get(M.repository.Tree, {'val2': 'test_set2'}), tree)
 
     @mock.patch('bson.ObjectId')
     def test_set_none_val(self, obj_id):
         obj_id.return_value = 'OBJID'
-        self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, None)
-        self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, None)
-        self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
+        self.cache.set(M.repository.Tree, {'val1': 'test_set1'}, None)
+        self.cache.set(M.repository.Tree, {'val2': 'test_set2'}, None)
+        self.assertEqual(dict(self.cache._query_cache[M.repository.Tree]), {
             (('val1', 'test_set1'),): None,
             (('val2', 'test_set2'),): None,
         })
-        self.assertEqual(dict(self.cache._instance_cache[M.repo.Tree]), {})
+        self.assertEqual(dict(self.cache._instance_cache[M.repository.Tree]), {})
         tree1 = mock.Mock(spec=['_id', 'val'], _id='tree1', val='test_set')
         tree2 = mock.Mock(spec=['_model_cache_id', '_id', 'val'],
                           _model_cache_id='tree2', _id='tree1', val='test_set2')
-        self.cache.set(M.repo.Tree, {'val1': 'test_set1'}, tree1)
-        self.cache.set(M.repo.Tree, {'val2': 'test_set2'}, tree2)
-        self.assertEqual(dict(self.cache._query_cache[M.repo.Tree]), {
+        self.cache.set(M.repository.Tree, {'val1': 'test_set1'}, tree1)
+        self.cache.set(M.repository.Tree, {'val2': 'test_set2'}, tree2)
+        self.assertEqual(dict(self.cache._query_cache[M.repository.Tree]), {
             (('val1', 'test_set1'),): 'tree1',
             (('val2', 'test_set2'),): 'tree2',
         })
-        self.assertEqual(dict(self.cache._instance_cache[M.repo.Tree]), {
+        self.assertEqual(dict(self.cache._instance_cache[M.repository.Tree]), {
             'tree1': tree1,
             'tree2': tree2,
         })
@@ -536,94 +536,94 @@ class TestModelCache(unittest.TestCase):
     def test_instance_ids(self):
         tree1 = mock.Mock(spec=['_id', 'val'], _id='id1', val='tree1')
         tree2 = mock.Mock(spec=['_id', 'val'], _id='id2', val='tree2')
-        self.cache.set(M.repo.Tree, {'val': 'tree1'}, tree1)
-        self.cache.set(M.repo.Tree, {'val': 'tree2'}, tree2)
-        self.assertEqual(set(self.cache.instance_ids(M.repo.Tree)),
+        self.cache.set(M.repository.Tree, {'val': 'tree1'}, tree1)
+        self.cache.set(M.repository.Tree, {'val': 'tree2'}, tree2)
+        self.assertEqual(set(self.cache.instance_ids(M.repository.Tree)),
                          set(['id1', 'id2']))
-        self.assertEqual(self.cache.instance_ids(M.repo.LastCommit), [])
+        self.assertEqual(self.cache.instance_ids(M.repository.LastCommit), [])
 
-    @mock.patch.object(M.repo.Tree.query, 'find')
+    @mock.patch.object(M.repository.Tree.query, 'find')
     def test_batch_load(self, tr_find):
         # cls, query, attrs
         m1 = mock.Mock(spec=['_id', 'foo', 'qux'], _id='id1', foo=1, qux=3)
         m2 = mock.Mock(spec=['_id', 'foo', 'qux'], _id='id2', foo=2, qux=5)
         tr_find.return_value = [m1, m2]
 
-        self.cache.batch_load(M.repo.Tree, {'foo': {'$in': 'bar'}})
+        self.cache.batch_load(M.repository.Tree, {'foo': {'$in': 'bar'}})
         tr_find.assert_called_with({'foo': {'$in': 'bar'}})
-        self.assertEqual(self.cache._query_cache[M.repo.Tree], {
+        self.assertEqual(self.cache._query_cache[M.repository.Tree], {
             (('foo', 1),): 'id1',
             (('foo', 2),): 'id2',
         })
-        self.assertEqual(self.cache._instance_cache[M.repo.Tree], {
+        self.assertEqual(self.cache._instance_cache[M.repository.Tree], {
             'id1': m1,
             'id2': m2,
         })
 
-    @mock.patch.object(M.repo.Tree.query, 'find')
+    @mock.patch.object(M.repository.Tree.query, 'find')
     def test_batch_load_attrs(self, tr_find):
         # cls, query, attrs
         m1 = mock.Mock(spec=['_id', 'foo', 'qux'], _id='id1', foo=1, qux=3)
         m2 = mock.Mock(spec=['_id', 'foo', 'qux'], _id='id2', foo=2, qux=5)
         tr_find.return_value = [m1, m2]
 
-        self.cache.batch_load(M.repo.Tree, {'foo': {'$in': 'bar'}}, ['qux'])
+        self.cache.batch_load(M.repository.Tree, {'foo': {'$in': 'bar'}}, ['qux'])
         tr_find.assert_called_with({'foo': {'$in': 'bar'}})
-        self.assertEqual(self.cache._query_cache[M.repo.Tree], {
+        self.assertEqual(self.cache._query_cache[M.repository.Tree], {
             (('qux', 3),): 'id1',
             (('qux', 5),): 'id2',
         })
-        self.assertEqual(self.cache._instance_cache[M.repo.Tree], {
+        self.assertEqual(self.cache._instance_cache[M.repository.Tree], {
             'id1': m1,
             'id2': m2,
         })
 
     def test_pruning(self):
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache expires as LRU
         tree1 = mock.Mock(spec=['_id', '_val'], _id='foo', val='bar')
         tree2 = mock.Mock(spec=['_id', '_val'], _id='qux', val='fuz')
         tree3 = mock.Mock(spec=['_id', '_val'], _id='f00', val='b4r')
         tree4 = mock.Mock(spec=['_id', '_val'], _id='foo', val='zaz')
-        cache.set(M.repo.Tree, {'_id': 'foo'}, tree1)
-        cache.set(M.repo.Tree, {'_id': 'qux'}, tree2)
-        cache.set(M.repo.Tree, {'_id': 'f00'}, tree3)
-        cache.set(M.repo.Tree, {'_id': 'foo'}, tree4)
-        cache.get(M.repo.Tree, {'_id': 'f00'})
-        cache.set(M.repo.Tree, {'val': 'b4r'}, tree3)
+        cache.set(M.repository.Tree, {'_id': 'foo'}, tree1)
+        cache.set(M.repository.Tree, {'_id': 'qux'}, tree2)
+        cache.set(M.repository.Tree, {'_id': 'f00'}, tree3)
+        cache.set(M.repository.Tree, {'_id': 'foo'}, tree4)
+        cache.get(M.repository.Tree, {'_id': 'f00'})
+        cache.set(M.repository.Tree, {'val': 'b4r'}, tree3)
         self.assertEqual(cache._query_cache, {
-            M.repo.Tree: {
+            M.repository.Tree: {
                 (('_id', 'foo'),): 'foo',
                 (('_id', 'f00'),): 'f00',
                 (('val', 'b4r'),): 'f00',
             },
         })
         self.assertEqual(cache._instance_cache, {
-            M.repo.Tree: {
+            M.repository.Tree: {
                 'f00': tree3,
                 'foo': tree4,
             },
         })
 
     def test_pruning_query_vs_instance(self):
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache expires as LRU
         tree1 = mock.Mock(spec=['_id', '_val'], _id='keep', val='bar')
         tree2 = mock.Mock(spec=['_id', '_val'], _id='tree2', val='fuz')
         tree3 = mock.Mock(spec=['_id', '_val'], _id='tree3', val='b4r')
         tree4 = mock.Mock(spec=['_id', '_val'], _id='tree4', val='zaz')
-        cache.set(M.repo.Tree, {'keep_query_1': 'bar'}, tree1)
-        cache.set(M.repo.Tree, {'drop_query_1': 'bar'}, tree2)
+        cache.set(M.repository.Tree, {'keep_query_1': 'bar'}, tree1)
+        cache.set(M.repository.Tree, {'drop_query_1': 'bar'}, tree2)
         # should refresh tree1 in _instance_cache
-        cache.set(M.repo.Tree, {'keep_query_2': 'bar'}, tree1)
+        cache.set(M.repository.Tree, {'keep_query_2': 'bar'}, tree1)
         # should drop tree2, not tree1, from _instance_cache
-        cache.set(M.repo.Tree, {'drop_query_2': 'bar'}, tree3)
-        self.assertEqual(cache._query_cache[M.repo.Tree], {
+        cache.set(M.repository.Tree, {'drop_query_2': 'bar'}, tree3)
+        self.assertEqual(cache._query_cache[M.repository.Tree], {
             (('drop_query_1', 'bar'),): 'tree2',
             (('keep_query_2', 'bar'),): 'keep',
             (('drop_query_2', 'bar'),): 'tree3',
         })
-        self.assertEqual(cache._instance_cache[M.repo.Tree], {
+        self.assertEqual(cache._instance_cache[M.repository.Tree], {
             'keep': tree1,
             'tree3': tree3,
         })
@@ -631,16 +631,16 @@ class TestModelCache(unittest.TestCase):
     @mock.patch('bson.ObjectId')
     def test_pruning_no_id(self, obj_id):
         obj_id.side_effect = ['id1', 'id2', 'id3']
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache considers same instance equal to itself, even if no _id
         tree1 = mock.Mock(spec=['val'], val='bar')
-        cache.set(M.repo.Tree, {'query_1': 'bar'}, tree1)
-        cache.set(M.repo.Tree, {'query_2': 'bar'}, tree1)
-        cache.set(M.repo.Tree, {'query_3': 'bar'}, tree1)
-        self.assertEqual(cache._instance_cache[M.repo.Tree], {
+        cache.set(M.repository.Tree, {'query_1': 'bar'}, tree1)
+        cache.set(M.repository.Tree, {'query_2': 'bar'}, tree1)
+        cache.set(M.repository.Tree, {'query_3': 'bar'}, tree1)
+        self.assertEqual(cache._instance_cache[M.repository.Tree], {
             'id1': tree1,
         })
-        self.assertEqual(cache._query_cache[M.repo.Tree], {
+        self.assertEqual(cache._query_cache[M.repository.Tree], {
             (('query_1', 'bar'),): 'id1',
             (('query_2', 'bar'),): 'id1',
             (('query_3', 'bar'),): 'id1',
@@ -649,39 +649,39 @@ class TestModelCache(unittest.TestCase):
     @mock.patch('bson.ObjectId')
     def test_pruning_none(self, obj_id):
         obj_id.side_effect = ['id1', 'id2', 'id3']
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache doesn't store None instances
-        cache.set(M.repo.Tree, {'query_1': 'bar'}, None)
-        cache.set(M.repo.Tree, {'query_2': 'bar'}, None)
-        cache.set(M.repo.Tree, {'query_3': 'bar'}, None)
-        self.assertEqual(cache._instance_cache[M.repo.Tree], {})
-        self.assertEqual(cache._query_cache[M.repo.Tree], {
+        cache.set(M.repository.Tree, {'query_1': 'bar'}, None)
+        cache.set(M.repository.Tree, {'query_2': 'bar'}, None)
+        cache.set(M.repository.Tree, {'query_3': 'bar'}, None)
+        self.assertEqual(cache._instance_cache[M.repository.Tree], {})
+        self.assertEqual(cache._query_cache[M.repository.Tree], {
             (('query_1', 'bar'),): None,
             (('query_2', 'bar'),): None,
             (('query_3', 'bar'),): None,
         })
 
-    @mock.patch('allura.model.repo.session')
-    @mock.patch.object(M.repo.Tree.query, 'get')
+    @mock.patch('allura.model.repository.session')
+    @mock.patch.object(M.repository.Tree.query, 'get')
     def test_pruning_query_flush(self, tr_get, session):
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache doesn't store None instances
         tree1 = mock.Mock(name='tree1',
                           spec=['_id', '_val'], _id='tree1', val='bar')
         tree2 = mock.Mock(name='tree2',
                           spec=['_id', '_val'], _id='tree2', val='fuz')
         tr_get.return_value = tree2
-        cache.set(M.repo.Tree, {'_id': 'tree1'}, tree1)
-        cache.set(M.repo.Tree, {'_id': 'tree2'}, tree2)
-        cache.get(M.repo.Tree, {'query_1': 'tree2'})
-        cache.get(M.repo.Tree, {'query_2': 'tree2'})
-        cache.get(M.repo.Tree, {'query_3': 'tree2'})
-        self.assertEqual(cache._query_cache[M.repo.Tree], {
+        cache.set(M.repository.Tree, {'_id': 'tree1'}, tree1)
+        cache.set(M.repository.Tree, {'_id': 'tree2'}, tree2)
+        cache.get(M.repository.Tree, {'query_1': 'tree2'})
+        cache.get(M.repository.Tree, {'query_2': 'tree2'})
+        cache.get(M.repository.Tree, {'query_3': 'tree2'})
+        self.assertEqual(cache._query_cache[M.repository.Tree], {
             (('query_1', 'tree2'),): 'tree2',
             (('query_2', 'tree2'),): 'tree2',
             (('query_3', 'tree2'),): 'tree2',
         })
-        self.assertEqual(cache._instance_cache[M.repo.Tree], {
+        self.assertEqual(cache._instance_cache[M.repository.Tree], {
             'tree1': tree1,
             'tree2': tree2,
         })
@@ -691,22 +691,22 @@ class TestModelCache(unittest.TestCase):
                          [mock.call(tree1), mock.call(tree2)])
         assert not session.return_value.expunge.called
 
-    @mock.patch('allura.model.repo.session')
+    @mock.patch('allura.model.repository.session')
     def test_pruning_instance_flush(self, session):
-        cache = M.repo.ModelCache(max_queries=3, max_instances=2)
+        cache = M.repository.ModelCache(max_queries=3, max_instances=2)
         # ensure cache doesn't store None instances
         tree1 = mock.Mock(spec=['_id', '_val'], _id='tree1', val='bar')
         tree2 = mock.Mock(spec=['_id', '_val'], _id='tree2', val='fuz')
         tree3 = mock.Mock(spec=['_id', '_val'], _id='tree3', val='qux')
-        cache.set(M.repo.Tree, {'_id': 'tree1'}, tree1)
-        cache.set(M.repo.Tree, {'_id': 'tree2'}, tree2)
-        cache.set(M.repo.Tree, {'_id': 'tree3'}, tree3)
-        self.assertEqual(cache._query_cache[M.repo.Tree], {
+        cache.set(M.repository.Tree, {'_id': 'tree1'}, tree1)
+        cache.set(M.repository.Tree, {'_id': 'tree2'}, tree2)
+        cache.set(M.repository.Tree, {'_id': 'tree3'}, tree3)
+        self.assertEqual(cache._query_cache[M.repository.Tree], {
             (('_id', 'tree1'),): 'tree1',
             (('_id', 'tree2'),): 'tree2',
             (('_id', 'tree3'),): 'tree3',
         })
-        self.assertEqual(cache._instance_cache[M.repo.Tree], {
+        self.assertEqual(cache._instance_cache[M.repository.Tree], {
             'tree2': tree2,
             'tree3': tree3,
         })

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/Allura/allura/tests/unit/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index eee886e..f2554fb 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -25,6 +25,7 @@ from pylons import tmpl_context as c
 from allura import model as M
 from allura.controllers.repository import topo_sort
 from allura.model.repository import zipdir, prefix_paths_union
+from allura.model.repo_refresh import CommitRunDoc, CommitRunBuilder
 from alluratest.controller import setup_unit_test
 
 
@@ -33,7 +34,7 @@ class TestCommitRunBuilder(unittest.TestCase):
     def setUp(self):
         setup_unit_test()
         commits = [
-            M.repo.CommitDoc.make(dict(
+            M.repository.CommitDoc.make(dict(
                 _id=str(i)))
             for i in range(10)]
         for p, c in zip(commits, commits[1:]):
@@ -44,35 +45,35 @@ class TestCommitRunBuilder(unittest.TestCase):
         self.commits = commits
 
     def test_single_pass(self):
-        crb = M.repo_refresh.CommitRunBuilder(
+        crb = CommitRunBuilder(
             [ci._id for ci in self.commits])
         crb.run()
-        self.assertEqual(M.repo.CommitRunDoc.m.count(), 1)
+        self.assertEqual(CommitRunDoc.m.count(), 1)
 
     def test_two_pass(self):
-        crb = M.repo_refresh.CommitRunBuilder(
+        crb = CommitRunBuilder(
             [ci._id for ci in self.commits[:5]])
         crb.run()
-        crb = M.repo_refresh.CommitRunBuilder(
+        crb = CommitRunBuilder(
             [ci._id for ci in self.commits[5:]])
         crb.run()
-        self.assertEqual(M.repo.CommitRunDoc.m.count(), 2)
+        self.assertEqual(CommitRunDoc.m.count(), 2)
         crb.cleanup()
-        self.assertEqual(M.repo.CommitRunDoc.m.count(), 1)
+        self.assertEqual(CommitRunDoc.m.count(), 1)
 
     def test_svn_like(self):
         for ci in self.commits:
-            crb = M.repo_refresh.CommitRunBuilder([ci._id])
+            crb = CommitRunBuilder([ci._id])
             crb.run()
             crb.cleanup()
-        self.assertEqual(M.repo.CommitRunDoc.m.count(), 1)
+        self.assertEqual(CommitRunDoc.m.count(), 1)
 
     def test_reversed(self):
         for ci in reversed(self.commits):
-            crb = M.repo_refresh.CommitRunBuilder([ci._id])
+            crb = CommitRunBuilder([ci._id])
             crb.run()
             crb.cleanup()
-        self.assertEqual(M.repo.CommitRunDoc.m.count(), 1)
+        self.assertEqual(CommitRunDoc.m.count(), 1)
 
 
 class TestTopoSort(unittest.TestCase):
@@ -129,9 +130,9 @@ def blob(name, id):
 
 class TestTree(unittest.TestCase):
 
-    @patch('allura.model.repo.Tree.__getitem__')
+    @patch('allura.model.repository.Tree.__getitem__')
     def test_get_obj_by_path(self, getitem):
-        tree = M.repo.Tree()
+        tree = M.repository.Tree()
         # test with relative path
         tree.get_obj_by_path('some/path/file.txt')
         getitem.assert_called_with('some')
@@ -147,7 +148,7 @@ class TestTree(unittest.TestCase):
 class TestBlob(unittest.TestCase):
 
     def test_pypeline_view(self):
-        blob = M.repo.Blob(Mock(), Mock(), Mock())
+        blob = M.repository.Blob(Mock(), Mock(), Mock())
         blob._id = 'blob1'
         blob.path = Mock(return_value='path')
         blob.name = 'INSTALL.mdown'
@@ -158,14 +159,14 @@ class TestBlob(unittest.TestCase):
 class TestCommit(unittest.TestCase):
 
     def test_activity_extras(self):
-        commit = M.repo.Commit()
+        commit = M.repository.Commit()
         commit.shorthand_id = MagicMock(return_value='abcdef')
         commit.message = 'commit msg'
         self.assertIn('allura_id', commit.activity_extras)
         self.assertEqual(commit.activity_extras['summary'], commit.summary)
 
     def test_get_path_no_create(self):
-        commit = M.repo.Commit()
+        commit = M.repository.Commit()
         commit.get_tree = MagicMock()
         commit.get_path('foo/', create=False)
         commit.get_tree.assert_called_with(False)
@@ -175,7 +176,7 @@ class TestCommit(unittest.TestCase):
     def test_get_tree_no_create(self):
         c.model_cache = Mock()
         c.model_cache.get.return_value = None
-        commit = M.repo.Commit()
+        commit = M.repository.Commit()
         commit.repo = Mock()
 
         commit.tree_id = None
@@ -187,7 +188,7 @@ class TestCommit(unittest.TestCase):
         commit.tree_id = 'tree'
         tree = commit.get_tree(create=False)
         assert not commit.repo.compute_tree_new.called
-        c.model_cache.get.assert_called_with(M.repo.Tree, dict(_id='tree'))
+        c.model_cache.get.assert_called_with(M.repository.Tree, dict(_id='tree'))
         assert_equal(tree, None)
 
         _tree = Mock()
@@ -196,11 +197,11 @@ class TestCommit(unittest.TestCase):
         _tree.set_context.assert_called_with(commit)
         assert_equal(tree, _tree)
 
-    @patch.object(M.repo.Tree.query, 'get')
+    @patch.object(M.repository.Tree.query, 'get')
     def test_get_tree_create(self, tree_get):
         c.model_cache = Mock()
         c.model_cache.get.return_value = None
-        commit = M.repo.Commit()
+        commit = M.repository.Commit()
         commit.repo = Mock()
 
         commit.repo.compute_tree_new.return_value = None
@@ -219,7 +220,7 @@ class TestCommit(unittest.TestCase):
         commit.repo.compute_tree_new.assert_called_once_with(commit)
         assert not tree_get.called
         c.model_cache.get.assert_called_once_with(
-            M.repo.Tree, dict(_id='tree'))
+            M.repository.Tree, dict(_id='tree'))
         _tree.set_context.assert_called_once_with(commit)
         assert_equal(tree, _tree)
 
@@ -230,7 +231,7 @@ class TestCommit(unittest.TestCase):
         assert not commit.repo.compute_tree_new.called
         assert not tree_get.called
         c.model_cache.get.assert_called_once_with(
-            M.repo.Tree, dict(_id='tree2'))
+            M.repository.Tree, dict(_id='tree2'))
         _tree.set_context.assert_called_once_with(commit)
         assert_equal(tree, _tree)
 
@@ -240,17 +241,17 @@ class TestCommit(unittest.TestCase):
         tree_get.return_value = _tree
         tree = commit.get_tree()
         c.model_cache.get.assert_called_once_with(
-            M.repo.Tree, dict(_id='tree2'))
+            M.repository.Tree, dict(_id='tree2'))
         commit.repo.compute_tree_new.assert_called_once_with(commit)
         assert_equal(commit.tree_id, 'tree')
         tree_get.assert_called_once_with(_id='tree')
         c.model_cache.set.assert_called_once_with(
-            M.repo.Tree, dict(_id='tree'), _tree)
+            M.repository.Tree, dict(_id='tree'), _tree)
         _tree.set_context.assert_called_once_with(commit)
         assert_equal(tree, _tree)
 
     def test_tree_create(self):
-        commit = M.repo.Commit()
+        commit = M.repository.Commit()
         commit.get_tree = Mock()
         tree = commit.tree
         commit.get_tree.assert_called_with(create=True)

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/Allura/test-light.py
----------------------------------------------------------------------
diff --git a/Allura/test-light.py b/Allura/test-light.py
index 95e9f92..be218b9 100644
--- a/Allura/test-light.py
+++ b/Allura/test-light.py
@@ -20,8 +20,8 @@ import sys
 from pylons import tmpl_context as c
 
 from allura.lib import helpers as h
-from allura.model.repo import CommitDoc, TreeDoc, TreesDoc, DiffInfoDoc
-from allura.model.repo import LastCommitDoc, CommitRunDoc
+from allura.model.repository import CommitDoc, TreeDoc, TreesDoc, DiffInfoDoc
+from allura.model.repository import LastCommitDoc, CommitRunDoc
 from allura.model.repo_refresh import refresh_repo
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index fef1b43..7fda67a 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -24,7 +24,6 @@ from datetime import datetime
 import tg
 import git
 import gitdb
-from pylons import app_globals as g
 from pylons import tmpl_context as c
 from pymongo.errors import DuplicateKeyError
 from paste.deploy.converters import asbool
@@ -175,13 +174,13 @@ class GitImplementation(M.RepositoryImplementation):
 
     def commit(self, rev):
         '''Return a Commit object.  rev can be _id or a branch/tag name'''
-        cache = getattr(c, 'model_cache', '') or M.repo.ModelCache()
-        result = cache.get(M.repo.Commit, dict(_id=rev))
+        cache = getattr(c, 'model_cache', '') or M.repository.ModelCache()
+        result = cache.get(M.repository.Commit, dict(_id=rev))
         if result is None:
             # find the id by branch/tag name
             try:
                 impl = self._git.rev_parse(str(rev) + '^0')
-                result = cache.get(M.repo.Commit, dict(_id=impl.hexsha))
+                result = cache.get(M.repository.Commit, dict(_id=impl.hexsha))
             except Exception:
                 url = ''
                 try:
@@ -218,7 +217,7 @@ class GitImplementation(M.RepositoryImplementation):
                 continue
             if not all_commits:
                 # Look up the object
-                if M.repo.Commit.query.find(dict(_id=obj.hexsha)).count():
+                if M.repository.Commit.query.find(dict(_id=obj.hexsha)).count():
                     graph[obj.hexsha] = set()  # mark as parentless
                     continue
             graph[obj.hexsha] = set(p.hexsha for p in obj.parents)
@@ -226,7 +225,7 @@ class GitImplementation(M.RepositoryImplementation):
         return list(topological_sort(graph))
 
     def refresh_commit_info(self, oid, seen, lazy=True):
-        from allura.model.repo import CommitDoc
+        from allura.model.repository import CommitDoc
         ci_doc = CommitDoc.m.get(_id=oid)
         if ci_doc and lazy:
             return False
@@ -258,7 +257,7 @@ class GitImplementation(M.RepositoryImplementation):
         return True
 
     def refresh_tree_info(self, tree, seen, lazy=True):
-        from allura.model.repo import TreeDoc
+        from allura.model.repository import TreeDoc
         if lazy and tree.binsha in seen:
             return
         seen.add(tree.binsha)

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 34b726b..4d7a0c0 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -171,8 +171,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         assert os.stat(
             os.path.join(g.tmpdir, 'testgit.git/hooks/post-receive'))[0] & stat.S_IXUSR
 
-    @mock.patch('forgegit.model.git_repo.g.post_event')
-    def test_clone(self, post_event):
+    def test_clone(self):
         repo = GM.Repository(
             name='testgit.git',
             fs_path=g.tmpdir + '/',
@@ -203,8 +202,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         shutil.rmtree(dirname)
 
     @mock.patch('forgegit.model.git_repo.git.Repo.clone_from')
-    @mock.patch('forgegit.model.git_repo.g.post_event')
-    def test_hotcopy(self, post_event, clone_from):
+    def test_hotcopy(self, clone_from):
         with h.push_config(tg.config, **{'scm.git.hotcopy': 'True'}):
             repo = GM.Repository(
                 name='testgit.git',
@@ -340,10 +338,10 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         assert str(entry.authored.name) == 'Rick Copeland', entry.authored
         assert entry.message
         # test the auto-gen tree fall-through
-        orig_tree = M.repo.Tree.query.get(_id=entry.tree_id)
+        orig_tree = M.repository.Tree.query.get(_id=entry.tree_id)
         assert orig_tree
         # force it to regenerate the tree
-        M.repo.Tree.query.remove(dict(_id=entry.tree_id))
+        M.repository.Tree.query.remove(dict(_id=entry.tree_id))
         session(orig_tree).flush()
         # ensure we don't just pull it from the session cache
         session(orig_tree).expunge(orig_tree)

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 6aa5499..af05713 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -42,6 +42,7 @@ from allura import model as M
 from allura.lib import helpers as h
 from allura.model.auth import User
 from allura.model.repository import zipdir
+from allura.model import repository as RM
 
 log = logging.getLogger(__name__)
 
@@ -309,7 +310,7 @@ class SVNImplementation(M.RepositoryImplementation):
 
     def commit(self, rev):
         oid = self.rev_parse(rev)
-        result = M.repo.Commit.query.get(_id=oid)
+        result = M.repository.Commit.query.get(_id=oid)
         if result:
             result.set_context(self._repo)
         return result
@@ -336,7 +337,7 @@ class SVNImplementation(M.RepositoryImplementation):
             return oids
         # Find max commit id -- everything greater than that will be "unknown"
         prefix = self._oid('')
-        q = M.repo.Commit.query.find(
+        q = M.repository.Commit.query.find(
             dict(
                 type='commit',
                 _id={'$gt': prefix},
@@ -353,7 +354,7 @@ class SVNImplementation(M.RepositoryImplementation):
             oid for oid in oids if oid not in seen_oids]
 
     def refresh_commit_info(self, oid, seen_object_ids, lazy=True):
-        from allura.model.repo import CommitDoc, DiffInfoDoc
+        from allura.model.repository import CommitDoc, DiffInfoDoc
         ci_doc = CommitDoc.m.get(_id=oid)
         if ci_doc and lazy:
             return False
@@ -440,7 +441,6 @@ class SVNImplementation(M.RepositoryImplementation):
         return True
 
     def compute_tree_new(self, commit, tree_path='/'):
-        from allura.model import repo as RM
         # always leading slash, never trailing
         tree_path = '/' + tree_path.strip('/')
         tree_id = self._tree_oid(commit._id, tree_path)

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 3ad13c7..a9d712d 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -363,7 +363,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         actual = entry.paged_diffs(start=1, end=3)
         self.assertEqual(expected, actual)
 
-        empty = M.repo.Commit().paged_diffs()
+        empty = M.repository.Commit().paged_diffs()
         self.assertEqual(sorted(actual.keys()), sorted(empty.keys()))
 
     def test_diff_create_file(self):
@@ -653,12 +653,12 @@ class _Test(unittest.TestCase):
     idgen = ('obj_%d' % i for i in count())
 
     def _make_tree(self, object_id, **kwargs):
-        t, isnew = M.repo.Tree.upsert(object_id)
+        t, isnew = M.repository.Tree.upsert(object_id)
         repo = getattr(self, 'repo', None)
         t.repo = repo
         for k, v in kwargs.iteritems():
             if isinstance(v, basestring):
-                obj = M.repo.Blob(
+                obj = M.repository.Blob(
                     t, k, self.idgen.next())
                 t.blob_ids.append(Object(
                     name=k, id=obj._id))
@@ -670,7 +670,7 @@ class _Test(unittest.TestCase):
         return t
 
     def _make_commit(self, object_id, **tree_parts):
-        ci, isnew = M.repo.Commit.upsert(object_id)
+        ci, isnew = M.repository.Commit.upsert(object_id)
         if isnew:
             ci.committed.email = c.user.email_addresses[0]
             ci.authored.email = c.user.email_addresses[0]
@@ -827,7 +827,7 @@ class TestRepo(_TestWithRepo):
             return_value=[['master', 'branch'], []])
 
         def refresh_commit_info(oid, seen, lazy=False):
-            M.repo.CommitDoc(dict(
+            M.repository.CommitDoc(dict(
                 authored=dict(
                     name=committer_name,
                     email=committer_email),
@@ -935,8 +935,8 @@ class TestMergeRequest(_TestWithRepoAndCommit):
 class TestRepoObject(_TestWithRepoAndCommit):
 
     def test_upsert(self):
-        obj0, isnew0 = M.repo.Tree.upsert('foo1')
-        obj1, isnew1 = M.repo.Tree.upsert('foo1')
+        obj0, isnew0 = M.repository.Tree.upsert('foo1')
+        obj1, isnew1 = M.repository.Tree.upsert('foo1')
         assert obj0 is obj1
         assert isnew0 and not isnew1
 
@@ -964,8 +964,8 @@ class TestCommit(_TestWithRepo):
         self.repo._impl.url_for_commit = impl.url_for_commit
 
     def test_upsert(self):
-        obj0, isnew0 = M.repo.Commit.upsert('foo')
-        obj1, isnew1 = M.repo.Commit.upsert('foo')
+        obj0, isnew0 = M.repository.Commit.upsert('foo')
+        obj1, isnew1 = M.repository.Commit.upsert('foo')
         assert obj0 is obj1
         assert not isnew1
         u = M.User.by_username('test-admin')
@@ -978,9 +978,9 @@ class TestCommit(_TestWithRepo):
 
     def test_get_path(self):
         b = self.ci.get_path('a/a/a')
-        assert isinstance(b, M.repo.Blob)
+        assert isinstance(b, M.repository.Blob)
         x = self.ci.get_path('a/a')
-        assert isinstance(x, M.repo.Tree)
+        assert isinstance(x, M.repository.Tree)
 
     def _unique_blobs(self):
         def counter():

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/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
index b9c75d3..c4ab72e 100644
--- a/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
+++ b/ForgeSVN/forgesvn/tests/model/test_svnimplementation.py
@@ -20,7 +20,7 @@ from nose.tools import assert_equal
 from pylons import app_globals as g
 
 from alluratest.controller import setup_unit_test
-from allura.model.repo import Commit
+from allura.model.repository import Commit
 from forgesvn.model.svn import SVNImplementation
 
 
@@ -35,10 +35,10 @@ class TestSVNImplementation(object):
         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')
+    @patch('allura.model.repository.LastCommitDoc.m.update_partial')
+    @patch('allura.model.repository.TreesDoc.m.update_partial')
+    @patch('allura.model.repository.Tree.upsert')
+    @patch('allura.model.repository.Tree.query.get')
     def _test_compute_tree_new(self, path, tree_get, tree_upsert, treesdoc_partial, lcd_partial):
         repo = Mock(fs_path=g.tmpdir + '/')
         repo.name = 'code'

http://git-wip-us.apache.org/repos/asf/allura/blob/e36b75dc/scripts/migrations/028-remove-svn-trees.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/028-remove-svn-trees.py b/scripts/migrations/028-remove-svn-trees.py
index 5b9a413..79e82aa 100644
--- a/scripts/migrations/028-remove-svn-trees.py
+++ b/scripts/migrations/028-remove-svn-trees.py
@@ -28,10 +28,10 @@ log = logging.getLogger(__name__)
 
 def kill_tree(repo, commit_id, path, tree):
     '''They were arboring terrorists, I swear.'''
-    M.repo.Tree.query.remove(dict(_id=tree._id))
+    M.repository.Tree.query.remove(dict(_id=tree._id))
     for tree_rec in tree.tree_ids:
         tid = repo._tree_oid(commit_id, path + '/' + tree_rec.name)
-        child_tree = M.repo.Tree.query.get(_id=tid)
+        child_tree = M.repository.Tree.query.get(_id=tid)
         if child_tree:
             print '  Found {0}'.format((path + '/' + tree_rec.name).encode('utf8'))
             kill_tree(repo, commit_id, path + '/' + tree_rec.name, child_tree)
@@ -45,8 +45,8 @@ def main():
             print 'Processing {0}'.format(r)
             all_commit_ids = r._impl.all_commit_ids()
             if all_commit_ids:
-                for commit in M.repo.Commit.query.find({'_id': {'$in': all_commit_ids}}):
-                    if commit.tree_id and M.repo.Tree.query.get(_id=commit.tree_id):
+                for commit in M.repository.Commit.query.find({'_id': {'$in': all_commit_ids}}):
+                    if commit.tree_id and M.repository.Tree.query.get(_id=commit.tree_id):
                         kill_tree(r._impl, commit._id, '', commit.tree)
                 ThreadLocalORMSession.flush_all()
                 ThreadLocalORMSession.close_all()


Mime
View raw message