incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#4691] Refactored LCD to store less data, fixed tests
Date Tue, 22 Jan 2013 17:31:10 GMT
Updated Branches:
  refs/heads/cj/4691 9926d4a76 -> 6331ec6f4


[#4691] Refactored LCD to store less data, fixed tests

Signed-off-by: Cory Johns <johnsca@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6331ec6f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6331ec6f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6331ec6f

Branch: refs/heads/cj/4691
Commit: 6331ec6f459afb4309a08283e3a69494b01e79d8
Parents: 9926d4a
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Jan 22 17:30:51 2013 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Jan 22 17:30:51 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py            |   63 +++---
 Allura/allura/tests/model/test_repo.py |  329 ++++-----------------------
 2 files changed, 77 insertions(+), 315 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6331ec6f/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 535afbf..4925bcd 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -84,7 +84,6 @@ LastCommitDoc = collection(
     Field('path', str),
     Index('commit_id', 'path'),
     Field('entries', [dict(
-        type=str,
         name=str,
         commit_id=str)]))
 
@@ -465,6 +464,7 @@ class Tree(RepoObject):
         # look for existing new format first
         last_commit = LastCommit.get(self, create=True)
         if last_commit:
+            session(last_commit).flush(last_commit)
             return self._lcd_map(last_commit)
         # otherwise, try old format
         old_style_results = self.ls_old()
@@ -476,27 +476,31 @@ class Tree(RepoObject):
     def _lcd_map(self, lcd):
         if lcd is None:
             return []
-        cmp_entries = lambda a,b: cmp(b.type,a.type) or cmp(a.name,b.name)
         commit_ids = [e.commit_id for e in lcd.entries]
         commits = Commit.query.find(dict(_id={'$in': commit_ids}))
         commit_infos = {c._id: c.info for c in commits}
+        by_name = lambda n: n.name
+        tree_names = sorted([n.name for n in self.tree_ids])
+        blob_names = sorted([n.name for n in chain(self.blob_ids, self.other_ids)])
+
         results = []
-        for entry in sorted(lcd.entries, cmp=cmp_entries):
-            commit_info = commit_infos[entry.commit_id]
-            results.append(dict(
-                    kind=entry.type,
-                    name=entry.name,
-                    href=entry.name,
-                    last_commit=dict(
-                            author=commit_info['author'],
-                            author_email=commit_info['author_email'],
-                            author_url=commit_info['author_url'],
-                            date=commit_info['date'],
-                            href=self.repo.url_for_commit(commit_info['id']),
-                            shortlink=commit_info['shortlink'],
-                            summary=commit_info['summary'],
-                        ),
-                ))
+        for type, names in (('DIR', tree_names), ('BLOB', blob_names)):
+            for name in names:
+                commit_info = commit_infos[lcd.by_name[name]]
+                results.append(dict(
+                        kind=type,
+                        name=name,
+                        href=name,
+                        last_commit=dict(
+                                author=commit_info['author'],
+                                author_email=commit_info['author_email'],
+                                author_url=commit_info['author_url'],
+                                date=commit_info['date'],
+                                href=self.repo.url_for_commit(commit_info['id']),
+                                shortlink=commit_info['shortlink'],
+                                summary=commit_info['summary'],
+                            ),
+                    ))
         return results
 
     def ls_old(self):
@@ -607,17 +611,17 @@ class Blob(object):
     def prev_commit(self):
         lc = LastCommit.get(self.tree)
         if lc:
-            entry = lc.entry_by_name(self.name)
-            last_commit = self.repo.commit(entry.commit_info.id)
+            entry = lc.by_name[self.name]
+            last_commit = self.repo.commit(entry.commit_id)
             prev_commit = last_commit.get_parent()
             try:
                 tree = prev_commit and prev_commit.get_path(self.tree.path().rstrip('/'))
             except KeyError:
                 return None
             lc = tree and LastCommit.get(tree)
-            entry = lc and lc.entry_by_name(self.name)
-            if entry:
-                prev_commit = self.repo.commit(entry.commit_info.id)
+            commit_id = lc and lc.by_name[self.name]
+            if commit_id:
+                prev_commit = self.repo.commit(commit_id)
                 return prev_commit
         return None
 
@@ -703,8 +707,6 @@ class LastCommit(RepoObject):
 
     @classmethod
     def _last_commit_id(cls, commit, path):
-        if not commit.repo:
-            import ipdb; ipdb.set_trace()
         commit_id = list(commit.repo.commits(path, commit._id, limit=1))
         if commit_id:
             commit_id = commit_id[0]
@@ -735,7 +737,6 @@ class LastCommit(RepoObject):
         '''
         path = tree.path().strip('/')
         entries = []
-        tree_nodes = set([n.name for n in tree.tree_ids])
         prev_lcd = None
         parent = tree.commit.get_parent()
         if parent:
@@ -746,12 +747,11 @@ class LastCommit(RepoObject):
         for node in chain(tree.tree_ids, tree.blob_ids, tree.other_ids):
             not_changed = os.path.join(path, node.name) not in tree.commit.changed_paths
             if not_changed and prev_lcd:
-                commit_id = prev_lcd.entry_by_name(node.name).commit_id
+                commit_id = prev_lcd.by_name[node.name]
             else:
                 commit_id = cls._last_commit_id(tree.commit, os.path.join(path, node.name))
             entries.append(dict(
                     name=node.name,
-                    type='DIR' if node.name in tree_nodes else 'BLOB',
                     commit_id=commit_id,
                 ))
         lcd = cls(
@@ -761,10 +761,9 @@ class LastCommit(RepoObject):
             )
         return lcd
 
-    def entry_by_name(self, name):
-        for node in self.entries:
-            if node.name == name:
-                return node
+    @LazyProperty
+    def by_name(self):
+        return {n.name: n.commit_id for n in self.entries}
 
 mapper(Commit, CommitDoc, repository_orm_session)
 mapper(Tree, TreeDoc, repository_orm_session)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6331ec6f/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 83c4cb4..5100ea1 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -1,5 +1,5 @@
 from datetime import datetime
-from collections import defaultdict
+from collections import defaultdict, OrderedDict
 import unittest
 import mock
 from nose.tools import assert_equal
@@ -80,8 +80,9 @@ class TestLastCommit(unittest.TestCase):
         setup_basic_test()
         setup_global_objects()
         c.model_cache = M.repo.ModelCache()
-        self.repo = mock.Mock('repo', _commits={}, _last_commit=None)
+        self.repo = mock.Mock('repo', _commits=OrderedDict(), _last_commit=None)
         self.repo.shorthand_for_commit = lambda _id: _id[:6]
+        self.repo.commits = self._commits
 
     def _build_tree(self, commit, path, tree_paths):
         tree_nodes = []
@@ -94,7 +95,8 @@ class TestLastCommit(unittest.TestCase):
         for p in tree_paths:
             if '/' in p:
                 node, sub = p.split('/',1)
-                tree_nodes.append(n(node))
+                if node not in sub_paths:
+                    tree_nodes.append(n(node))
                 sub_paths[node].append(sub)
             else:
                 blob_nodes.append(n(p))
@@ -104,8 +106,10 @@ class TestLastCommit(unittest.TestCase):
                 tree_ids=tree_nodes,
                 blob_ids=blob_nodes,
                 other_ids=[],
+                repo=self.repo,
             )
         tree.get_obj_by_path = lambda p: self._build_tree(commit, p, sub_paths[p])
+        tree.__getitem__ = lambda s, p: self._build_tree(commit, p, sub_paths[p])
         return tree
 
     def _add_commit(self, msg, tree_paths, diff_paths=None, parents=[]):
@@ -131,163 +135,56 @@ class TestLastCommit(unittest.TestCase):
         self.repo._commits[commit._id] = commit
         return commit
 
+    def _commits(self, path, commit_id, limit):
+        return [c._id for c in reversed(self.repo._commits.values()) if path in c.changed_paths][:limit]
+
     def test_single_commit(self):
         commit1 = self._add_commit('Commit 1', [
                 'file1',
                 'dir1/file2',
             ])
         lcd = M.repo.LastCommit.get(commit1.tree)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit1.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 1',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 1),
-                author_url=None,
-                id=commit1._id,
-                shortlink=self.repo.shorthand_for_commit(commit1._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('dir1'), dict(
-            type='DIR',
-            name='dir1',
-            commit_info=dict(
-                summary='Commit 1',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 1),
-                author_url=None,
-                id=commit1._id,
-                shortlink=self.repo.shorthand_for_commit(commit1._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit1._id)
+        self.assertEqual(lcd.by_name['dir1'], commit1._id)
 
     def test_multiple_commits_no_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
         commit2 = self._add_commit('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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit3.message])
-        self.assertEqual(lcd.commit_ids, [commit3._id])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
+        self.assertEqual(lcd.commit_id, commit3._id)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 1',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 1),
-                author_url=None,
-                id=commit1._id,
-                shortlink=self.repo.shorthand_for_commit(commit1._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('dir1'), dict(
-            type='DIR',
-            name='dir1',
-            commit_info=dict(
-                summary='Commit 2',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 2),
-                author_url=None,
-                id=commit2._id,
-                shortlink=self.repo.shorthand_for_commit(commit2._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file2'), dict(
-            type='BLOB',
-            name='file2',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit1._id)
+        self.assertEqual(lcd.by_name['dir1'], commit2._id)
+        self.assertEqual(lcd.by_name['file2'], commit3._id)
 
     def test_multiple_commits_with_overlap(self):
         commit1 = self._add_commit('Commit 1', ['file1'])
         commit2 = self._add_commit('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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit3.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 3)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('dir1'), dict(
-            type='DIR',
-            name='dir1',
-            commit_info=dict(
-                summary='Commit 2',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 2),
-                author_url=None,
-                id=commit2._id,
-                shortlink=self.repo.shorthand_for_commit(commit2._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file2'), dict(
-            type='BLOB',
-            name='file2',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit3._id)
+        self.assertEqual(lcd.by_name['dir1'], commit2._id)
+        self.assertEqual(lcd.by_name['file2'], commit3._id)
 
     def test_multiple_commits_subdir_change(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
         commit2 = self._add_commit('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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit3.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, '')
         self.assertEqual(len(lcd.entries), 2)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 1',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 1),
-                author_url=None,
-                id=commit1._id,
-                shortlink=self.repo.shorthand_for_commit(commit1._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('dir1'), dict(
-            type='DIR',
-            name='dir1',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit1._id)
+        self.assertEqual(lcd.by_name['dir1'], commit3._id)
 
     def test_subdir_lcd(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
@@ -295,33 +192,11 @@ 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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit3.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file2'), dict(
-            type='BLOB',
-            name='file2',
-            commit_info=dict(
-                summary='Commit 2',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 2),
-                author_url=None,
-                id=commit2._id,
-                shortlink=self.repo.shorthand_for_commit(commit2._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit3._id)
+        self.assertEqual(lcd.by_name['file2'], commit2._id)
 
     def test_subdir_lcd_prev_commit(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1/file1'])
@@ -330,40 +205,18 @@ 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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit4.message,
commit3.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit3.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(len(lcd.entries), 2)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file2'), dict(
-            type='BLOB',
-            name='file2',
-            commit_info=dict(
-                summary='Commit 2',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 2),
-                author_url=None,
-                id=commit2._id,
-                shortlink=self.repo.shorthand_for_commit(commit2._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit3._id)
+        self.assertEqual(lcd.by_name['file2'], commit2._id)
 
     def test_subdir_lcd_always_empty(self):
         commit1 = self._add_commit('Commit 1', ['file1', 'dir1'])
         commit2 = self._add_commit('Commit 2', ['file1', 'file2'], ['file2'], [commit1])
         tree = self._build_tree(commit2, '/dir1', [])
         lcd = M.repo.LastCommit.get(tree)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit2.message,
commit1.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit1.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
@@ -372,7 +225,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)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit2.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, [])
 
@@ -382,39 +235,21 @@ class TestLastCommit(unittest.TestCase):
         commit3 = self._add_commit('Commit 3', ['file1', 'dir1/file1', 'dir1/file2'], ['file1'],
[commit2])
         prev_lcd = M.repo.LastCommit(
                 path='dir1',
-                commit_ids=[commit2._id],
+                commit_id=commit2._id,
                 entries=[
                     dict(
-                        type='BLOB',
                         name='file1',
-                        commit_info=dict(
-                            summary='Commit 1',
-                            author='test',
-                            author_email='test@example.com',
-                            date=datetime(2013, 1, 1),
-                            author_url=None,
-                            id=commit1._id,
-                            shortlink=self.repo.shorthand_for_commit(commit1._id),
-                        )),
+                        commit_id=commit1._id),
                     dict(
-                        type='BLOB',
                         name='file2',
-                        commit_info=dict(
-                            summary='Commit 2',
-                            author='test',
-                            author_email='test@example.com',
-                            date=datetime(2013, 1, 2),
-                            author_url=None,
-                            id=commit2._id,
-                            shortlink=self.repo.shorthand_for_commit(commit2._id),
-                        )),
+                        commit_id=commit2._id),
                 ],
             )
         session(prev_lcd).flush()
         tree = self._build_tree(commit3, '/dir1', ['file1', 'file2'])
         lcd = M.repo.LastCommit.get(tree)
         self.assertEqual(lcd._id, prev_lcd._id)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit2.message,
commit3.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit2.message)
         self.assertEqual(lcd.path, 'dir1')
         self.assertEqual(lcd.entries, prev_lcd.entries)
 
@@ -425,100 +260,28 @@ class TestLastCommit(unittest.TestCase):
         commit4 = self._add_commit('Commit 4', ['file1', 'file2', 'file3', 'file4'], ['file2',
'file4'], [commit3])
         prev_lcd = M.repo.LastCommit(
                 path='',
-                commit_ids=[commit3._id],
+                commit_id=commit3._id,
                 entries=[
                     dict(
-                        type='BLOB',
                         name='file1',
-                        commit_info=dict(
-                            summary='Existing LCD',    # lying here to test that it uses
this
-                            author='test',             # data instead of walking up the tree
-                            author_email='test@example.com',
-                            date=datetime(2013, 1, 1),
-                            author_url=None,
-                            id=commit1._id,
-                            shortlink=self.repo.shorthand_for_commit(commit1._id),
-                        )),
+                        commit_id=commit1._id),
                     dict(
-                        type='BLOB',
                         name='file2',
-                        commit_info=dict(
-                            summary='Commit 2',
-                            author='test',
-                            author_email='test@example.com',
-                            date=datetime(2013, 1, 2),
-                            author_url=None,
-                            id=commit2._id,
-                            shortlink=self.repo.shorthand_for_commit(commit2._id),
-                        )),
+                        commit_id=commit2._id),
                     dict(
-                        type='BLOB',
                         name='file3',
-                        commit_info=dict(
-                            summary='Commit 3',
-                            author='test',
-                            author_email='test@example.com',
-                            date=datetime(2013, 1, 3),
-                            author_url=None,
-                            id=commit3._id,
-                            shortlink=self.repo.shorthand_for_commit(commit3._id),
-                        )),
+                        commit_id=commit3._id),
                 ],
             )
         session(prev_lcd).flush()
         lcd = M.repo.LastCommit.get(commit4.tree)
-        self.assertEqual([self.repo._commits[c].message for c in lcd.commit_ids], [commit4.message])
+        self.assertEqual(self.repo._commits[lcd.commit_id].message, commit4.message)
         self.assertEqual(lcd.path, '')
-        self.assertEqual(lcd.entry_by_name('file1')['commit_info']['summary'], 'Existing
LCD')
         self.assertEqual(len(lcd.entries), 4)
-        self.assertEqual(lcd.entry_by_name('file1'), dict(
-            type='BLOB',
-            name='file1',
-            commit_info=dict(
-                summary='Existing LCD',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 1),
-                author_url=None,
-                id=commit1._id,
-                shortlink=self.repo.shorthand_for_commit(commit1._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file2'), dict(
-            type='BLOB',
-            name='file2',
-            commit_info=dict(
-                summary='Commit 4',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 4),
-                author_url=None,
-                id=commit4._id,
-                shortlink=self.repo.shorthand_for_commit(commit4._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file3'), dict(
-            type='BLOB',
-            name='file3',
-            commit_info=dict(
-                summary='Commit 3',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 3),
-                author_url=None,
-                id=commit3._id,
-                shortlink=self.repo.shorthand_for_commit(commit3._id),
-            )))
-        self.assertEqual(lcd.entry_by_name('file4'), dict(
-            type='BLOB',
-            name='file4',
-            commit_info=dict(
-                summary='Commit 4',
-                author='test',
-                author_email='test@example.com',
-                date=datetime(2013, 1, 4),
-                author_url=None,
-                id=commit4._id,
-                shortlink=self.repo.shorthand_for_commit(commit4._id),
-            )))
+        self.assertEqual(lcd.by_name['file1'], commit1._id)
+        self.assertEqual(lcd.by_name['file2'], commit4._id)
+        self.assertEqual(lcd.by_name['file3'], commit3._id)
+        self.assertEqual(lcd.by_name['file4'], commit4._id)
 
 
 class TestModelCache(unittest.TestCase):


Mime
View raw message