Commits

Marcin Kuzminski committed 4abfb1a

fixes #630 git statistics do too much work making them slow.
added/changed/removed methods didn't use generator methods to return the list of changes
- added test for that case

Comments (0)

Files changed (2)

rhodecode/lib/vcs/backends/git/changeset.py

 from rhodecode.lib.vcs.exceptions import ImproperArchiveTypeError
 from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
 from rhodecode.lib.vcs.nodes import FileNode, DirNode, NodeKind, RootNode, \
-    RemovedFileNode, SubModuleNode
+    RemovedFileNode, SubModuleNode, ChangedFileNodesGenerator,\
+    AddedFileNodesGenerator, RemovedFileNodesGenerator
 from rhodecode.lib.vcs.utils import safe_unicode
 from rhodecode.lib.vcs.utils import date_fromtimestamp
 from rhodecode.lib.vcs.utils.lazy import LazyProperty
         """
         if not self.parents:
             return list(self._get_file_nodes())
-        return [self.get_node(path) for path in self._get_paths_for_status('added')]
+        return AddedFileNodesGenerator([n for n in
+                                self._get_paths_for_status('added')], self)
 
     @LazyProperty
     def changed(self):
         """
         if not self.parents:
             return []
-        return [self.get_node(path) for path in self._get_paths_for_status('modified')]
+        return ChangedFileNodesGenerator([n for n in
+                                self._get_paths_for_status('modified')], self)
 
     @LazyProperty
     def removed(self):
         """
         if not self.parents:
             return []
-        return [RemovedFileNode(path) for path in self._get_paths_for_status('deleted')]
+        return RemovedFileNodesGenerator([n for n in
+                                self._get_paths_for_status('deleted')], self)

rhodecode/tests/vcs/test_changesets.py

 from base import BackendTestMixin
 from conf import SCM_TESTS
 from rhodecode.lib.vcs.backends.base import BaseChangeset
-from rhodecode.lib.vcs.nodes import FileNode
+from rhodecode.lib.vcs.nodes import FileNode, AddedFileNodesGenerator,\
+    ChangedFileNodesGenerator, RemovedFileNodesGenerator
 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
 from rhodecode.lib.vcs.exceptions import RepositoryError
 
     def test_head_added(self):
         changeset = self.repo.get_changeset()
+        self.assertTrue(isinstance(changeset.added, AddedFileNodesGenerator))
         self.assertItemsEqual(changeset.added, [
             changeset.get_node('fallout'),
         ])
+        self.assertTrue(isinstance(changeset.changed, ChangedFileNodesGenerator))
         self.assertItemsEqual(changeset.changed, [
             changeset.get_node('foo/bar'),
             changeset.get_node('foobar'),
         ])
+        self.assertTrue(isinstance(changeset.removed, RemovedFileNodesGenerator))
         self.assertEqual(len(changeset.removed), 1)
         self.assertEqual(list(changeset.removed)[0].path, 'qwe')