Changeset - 59670f091c76
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2010-11-11 01:33:26
marcin@python-works.com
bugfix, repo_size crashed when broken symlinks where inside a repository.
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/hooks.py
Show inline comments
 
@@ -28,28 +28,34 @@ from rhodecode.lib import helpers as h
 
from rhodecode.lib.utils import action_logger
 
import os
 
import sys
 

	
 
def repo_size(ui, repo, hooktype=None, **kwargs):
 

	
 
    if hooktype != 'changegroup':
 
        return False
 
    size_hg, size_root = 0, 0
 
    for path, dirs, files in os.walk(repo.root):
 
        if path.find('.hg') != -1:
 
            for f in files:
 
                try:
 
                size_hg += os.path.getsize(os.path.join(path, f))
 
                except OSError:
 
                    pass
 
        else:
 
            for f in files:
 
                try:
 
                size_root += os.path.getsize(os.path.join(path, f))
 
                except OSError:
 
                    pass
 
                
 
    size_hg_f = h.format_byte_size(size_hg)
 
    size_root_f = h.format_byte_size(size_root)
 
    size_total_f = h.format_byte_size(size_root + size_hg)
 
    sys.stdout.write('Repository size .hg:%s repo:%s total:%s\n' \
 
                     % (size_hg_f, size_root_f, size_total_f))
 
    
 
def log_pull_action(ui, repo, **kwargs):
 
    """
 
    Logs user last pull action
 
    :param ui:
 
    :param repo:
0 comments (0 inline, 0 general)