Changeset - 8a9d93838882
[Not reviewed]
stable
0 3 0
domruf - 10 years ago 2016-04-19 19:53:16
dominikruf@gmail.com
vcs: fix repo size calculation

tip.walk already 'dives into' the dirs - don't do that twice.
3 files changed with 2 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/base.py
Show inline comments
 
@@ -120,15 +120,12 @@ class BaseRepository(object):
 
        size = 0
 
        try:
 
            tip = self.get_changeset()
 
            for topnode, dirs, files in tip.walk('/'):
 
                for f in files:
 
                    size += tip.get_file_size(f.path)
 
                for dir in dirs:
 
                    for f in files:
 
                        size += tip.get_file_size(f.path)
 

	
 
        except RepositoryError as e:
 
            pass
 
        return size
 

	
 
    def is_valid(self):
kallithea/tests/vcs/test_git.py
Show inline comments
 
@@ -387,13 +387,13 @@ class GitChangesetTest(unittest.TestCase
 
            ('6892503fb8f2a552cef5f4d4cc2cdbd13ae1cd2f', '/', 671830),
 
        )
 
        for revision, path, size in to_check:
 
            self._test_dir_size(revision, path, size)
 

	
 
    def test_repo_size(self):
 
        self.assertEqual(self.repo.size, 1022026) # FIXME
 
        self.assertEqual(self.repo.size, 674076)
 

	
 
    def test_file_history(self):
 
        # we can only check if those revisions are present in the history
 
        # as we cannot update this test every time file is changed
 
        files = {
 
            'setup.py': [
kallithea/tests/vcs/test_hg.py
Show inline comments
 
@@ -351,13 +351,13 @@ class MercurialChangesetTest(unittest.Te
 
            ('90243de06161', '/', 682006),
 
        )
 
        for revision, path, size in to_check:
 
            self._test_dir_size(revision, path, size)
 

	
 
    def test_repo_size(self):
 
        self.assertEqual(self.repo.size, 1042958) # FIXME
 
        self.assertEqual(self.repo.size, 682421)
 

	
 
    def test_file_history(self):
 
        # we can only check if those revisions are present in the history
 
        # as we cannot update this test every time file is changed
 
        files = {
 
            'setup.py': [7, 18, 45, 46, 47, 69, 77],
0 comments (0 inline, 0 general)