Edgewall Software

Ticket #4988: svn_fs.py.2.diff

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

Second version of patch that tracks across path changes

  • 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    cur_path = svn_path 
     81     
     82    while start <= cur_end: 
     83        history = [] 
    10084 
     85        cur_start = cur_end - 50 
     86        if cur_start < start: 
     87            cur_start = start 
     88 
     89        try: 
     90            if hasattr(repos, 'svn_repos_history2'): 
     91                # For Subversion >= 1.1 
     92                def authz_cb(root, path, pool): 
     93                    if limit and len(history) >= limit: 
     94                        return 0 
     95                    return authz.has_permission(_from_svn(path)) and 1 or 0 
     96                def history2_cb(path, rev, pool): 
     97                    history.append((_from_svn(path), rev)) 
     98                repos.svn_repos_history2(fs_ptr, cur_path, history2_cb, authz_cb, 
     99                                         cur_start, cur_end, 1, pool()) 
     100            else: 
     101                # For Subversion 1.0.x 
     102                def history_cb(path, rev, pool): 
     103                    path = _from_svn(path) 
     104                    if authz.has_permission(path): 
     105                        history.append((path, rev)) 
     106 
     107                repos.svn_repos_history(fs_ptr, cur_path, history_cb, 
     108                                        cur_start, cur_end, 1, pool()) 
     109        except (core.SubversionException): 
     110            pass 
     111             
     112        cur_end = cur_start - 1 
     113         
     114        for item in history: 
     115            p = _to_svn(item[0]) 
     116            if p != cur_path: 
     117                cur_path = p 
     118                 
     119            yield item 
     120 
    101121def _to_svn(*args): 
    102122    """Expect a list of `unicode` path components. 
    103123    Returns an UTF-8 encoded string suitable for the Subversion python bindings.