Edgewall Software

Ticket #7715: 7715-scoped-repositories-r8345.patch

File 7715-scoped-repositories-r8345.patch, 6.1 KB (added by rblank, 3 years ago)

Fix for scoped repositories.

  • trac/versioncontrol/cache.py

    diff --git a/trac/versioncontrol/cache.py b/trac/versioncontrol/cache.py
    a b  
    4040 
    4141    has_linear_changesets = False 
    4242 
     43    scope = property(lambda self: self.repos.scope) 
     44     
    4345    def __init__(self, getdb, repos, authz, log): 
    4446        Repository.__init__(self, repos.name, authz, log) 
    4547        if callable(getdb): 
  • trac/versioncontrol/svn_prop.py

    diff --git a/trac/versioncontrol/svn_prop.py b/trac/versioncontrol/svn_prop.py
    a b  
    2222 
    2323from trac.core import * 
    2424from trac.versioncontrol import NoSuchNode 
     25from trac.versioncontrol.svn_fs import _path_within_scope 
    2526from trac.versioncontrol.web_ui.browser import IPropertyRenderer 
    2627from trac.versioncontrol.web_ui.changeset import IPropertyDiffRenderer 
    2728from trac.util import Ranges, to_ranges 
     
    131132        rows = [] 
    132133        for line in props[name].splitlines(): 
    133134            path, revs = line.split(':', 1) 
    134             spath = path.strip('/') 
     135            spath = _path_within_scope(repos.scope, path) 
     136            if spath is None: 
     137                continue 
    135138            revs = revs.strip() 
    136139            deleted = False 
    137140            if 'LOG_VIEW' in context.perm('source', spath): 
    138141                try: 
    139142                    node = repos.get_node(spath, target_rev) 
    140                     row = [self._get_source_link(path, context), 
     143                    row = [self._get_source_link(spath, context), 
    141144                           self._get_revs_link(revs_label, context, 
    142145                                               spath, revs)] 
    143146                    if has_eligible: 
     
    157160            revs = revs.replace(',', u',\u200b') 
    158161            rows.append((deleted, spath, 
    159162                         [tag.td(path), tag.td(revs, colspan=revs_cols)])) 
     163        if not rows: 
     164            return None 
    160165        rows.sort() 
    161166        has_deleted = rows and rows[-1][0] or None 
    162167        return tag(has_deleted and tag.a(_('(toggle deleted branches)'), 
     
    164169                                         href='#'), 
    165170                   tag.table(tag.tbody( 
    166171                       [tag.tr(row, class_=deleted and 'trac-deleted' or None) 
    167                         for deleted, p, row in rows]), class_='props')) 
     172                        for deleted, spath, row in rows]), class_='props')) 
    168173 
    169174    def _get_blocked_revs(self, props, name, path): 
    170175        """Return the revisions blocked from merging for the given property 
     
    183188                pass 
    184189        return "" 
    185190 
    186     def _get_source_link(self, path, context): 
     191    def _get_source_link(self, spath, context): 
    187192        """Return a link to a merge source.""" 
    188         return tag.a(path, title=_('View merge source'), 
    189                      href=context.href.browser(path, 
     193        return tag.a('/' + spath, title=_('View merge source'), 
     194                     href=context.href.browser(spath, 
    190195                                               rev=context.resource.version)) 
    191196 
    192197    def _get_revs_link(self, label, context, spath, revs): 
     
    217222        # Build 3 columns table showing modifications on merge sources 
    218223        # || source || added revs || removed revs || 
    219224        # || source || removed                    || 
     225        repos = self.env.get_repository() 
    220226        def parse_sources(props): 
    221227            sources = {} 
    222228            for line in props[name].splitlines(): 
    223229                path, revs = line.split(':', 1) 
    224                 spath = path.strip('/') 
    225                 sources[spath] = (path, set(Ranges(revs.strip()))) 
     230                spath = _path_within_scope(repos.scope, path) 
     231                if spath is not None: 
     232                    sources[spath] = set(Ranges(revs.strip())) 
    226233            return sources 
    227234        old_sources = parse_sources(old_props) 
    228235        new_sources = parse_sources(new_props) 
     
    235242                revs = to_ranges(revs) 
    236243                return self._get_revs_link(revs.replace(',', u',\u200b'), 
    237244                                           context, spath, revs) 
    238         repos = self.env.get_repository() 
    239245        modified_sources = [] 
    240         for spath, (path, new_revs) in new_sources.iteritems(): 
     246        for spath, new_revs in new_sources.iteritems(): 
    241247            if spath in old_sources: 
    242                 old_revs, status = old_sources.pop(spath)[1], None 
     248                old_revs, status = old_sources.pop(spath), None 
    243249            else: 
    244250                old_revs, status = set(), _(' (added)') 
    245251            added = new_revs - old_revs 
     
    254260                pass 
    255261            if added or removed: 
    256262                modified_sources.append(( 
    257                     path, [self._get_source_link(path, new_context), status], 
     263                    spath, [self._get_source_link(spath, new_context), status], 
    258264                    added and tag(added_label, revs_link(added, new_context)), 
    259265                    removed and tag(removed_label, 
    260266                                    revs_link(removed, old_context)))) 
    261267        # Go through remaining old sources, those were deleted 
    262268        removed_sources = [] 
    263269        for spath, (path, old_revs) in old_sources.iteritems(): 
    264             removed_sources.append((path, 
    265                                     self._get_source_link(path, old_context))) 
     270            removed_sources.append((spath, 
     271                                    self._get_source_link(spath, old_context))) 
    266272        if modified_sources or removed_sources: 
    267273            modified_sources.sort() 
    268274            removed_sources.sort() 
    269275            changes = tag.table(tag.tbody( 
    270276                [tag.tr(tag.td(src), tag.td(added), tag.td(removed)) 
    271                  for p, src, added, removed in modified_sources], 
     277                 for spath, src, added, removed in modified_sources], 
    272278                [tag.tr(tag.td(src), tag.td(_('removed'), colspan=2)) 
    273                  for p, src in removed_sources]), class_='props') 
     279                 for spath, src in removed_sources]), class_='props') 
    274280        else: 
    275281            changes = tag.em(_(' (with no actual effect on merging)')) 
    276282        return tag.li(tag('Property ', tag.strong(name), ' changed'),