Edgewall Software

Ticket #4988: svn_fs.py.diff

File svn_fs.py.diff, 2.7 KB (added by csapuntz@…, 22 months ago)

Diff to optimize _get_history in svn_fs.py

  • svn_fs.py

     
    7676def _get_history(svn_path, authz, fs_ptr, pool, start, end, limit=None): 
    7777    """`svn_path` is assumed to be a UTF-8 encoded string. 
    7878    Returned history paths will be `unicode` objects though.""" 
    79     history = [] 
    80     if hasattr(repos, 'svn_repos_history2'): 
    81         # For Subversion >= 1.1 
    82         def authz_cb(root, path, pool): 
    83             if limit and len(history) >= limit: 
    84                 return 0 
    85             return authz.has_permission(_from_svn(path)) and 1 or 0 
    86         def history2_cb(path, rev, pool): 
    87             history.append((_from_svn(path), rev)) 
    88         repos.svn_repos_history2(fs_ptr, svn_path, history2_cb, authz_cb, 
    89                                  start, end, 1, pool()) 
    90     else: 
    91         # For Subversion 1.0.x 
    92         def history_cb(path, rev, pool): 
    93             path = _from_svn(path) 
    94             if authz.has_permission(path): 
    95                 history.append((path, rev)) 
    96         repos.svn_repos_history(fs_ptr, svn_path, history_cb, 
    97                                 start, end, 1, pool()) 
    98     for item in history: 
    99         yield item 
     79    cur_end = end 
     80     
     81    while start <= cur_end: 
     82        history = [] 
    10083 
     84        cur_start = cur_end - 50 
     85        if cur_start < start: 
     86            cur_start = start 
     87 
     88        try: 
     89            if hasattr(repos, 'svn_repos_history2'): 
     90                # For Subversion >= 1.1 
     91                def authz_cb(root, path, pool): 
     92                    if limit and len(history) >= limit: 
     93                        return 0 
     94                    return authz.has_permission(_from_svn(path)) and 1 or 0 
     95                def history2_cb(path, rev, pool): 
     96                    history.append((_from_svn(path), rev)) 
     97                repos.svn_repos_history2(fs_ptr, svn_path, history2_cb, authz_cb, 
     98                                         cur_start, cur_end, 1, pool()) 
     99            else: 
     100                # For Subversion 1.0.x 
     101                def history_cb(path, rev, pool): 
     102                    path = _from_svn(path) 
     103                    if authz.has_permission(path): 
     104                        history.append((path, rev)) 
     105 
     106                repos.svn_repos_history(fs_ptr, svn_path, history_cb, 
     107                                        cur_start, cur_end, 1, pool()) 
     108        except (core.SubversionException): 
     109            pass 
     110             
     111        cur_end = cur_start - 1 
     112         
     113        for item in history: 
     114            yield item 
     115 
    101116def _to_svn(*args): 
    102117    """Expect a list of `unicode` path components. 
    103118    Returns an UTF-8 encoded string suitable for the Subversion python bindings.