1. edgewall
  2. Trac

Commits

Remy Blank  committed 3bae8e3

0.11-stable: Fixed display of merge properties for scoped repositories.

Part of #7715.

  • Participants
  • Parent commits b66b432
  • Branches 0.11-stable

Comments (0)

Files changed (2)

File trac/versioncontrol/cache.py

View file
 
     has_linear_changesets = False
 
+    scope = property(lambda self: self.repos.scope)
+    
     def __init__(self, getdb, repos, authz, log):
         Repository.__init__(self, repos.name, authz, log)
         if callable(getdb):

File trac/versioncontrol/svn_prop.py

View file
 
 from trac.core import *
 from trac.versioncontrol import NoSuchNode
+from trac.versioncontrol.svn_fs import _path_within_scope
 from trac.versioncontrol.web_ui.browser import IPropertyRenderer
 from trac.versioncontrol.web_ui.changeset import IPropertyDiffRenderer
 from trac.util import Ranges, to_ranges
         rows = []
         for line in props[name].splitlines():
             path, revs = line.split(':', 1)
-            spath = path.strip('/')
+            spath = _path_within_scope(repos.scope, path)
+            if spath is None:
+                continue
             revs = revs.strip()
             deleted = False
             if 'LOG_VIEW' in context.perm('source', spath):
                 try:
                     node = repos.get_node(spath, target_rev)
-                    row = [self._get_source_link(path, context),
+                    row = [self._get_source_link(spath, context),
                            self._get_revs_link(revs_label, context,
                                                spath, revs)]
                     if has_eligible:
             revs = revs.replace(',', u',\u200b')
             rows.append((deleted, spath,
                          [tag.td(path), tag.td(revs, colspan=revs_cols)]))
+        if not rows:
+            return None
         rows.sort()
         has_deleted = rows and rows[-1][0] or None
         return tag(has_deleted and tag.a(_('(toggle deleted branches)'),
                                          href='#'),
                    tag.table(tag.tbody(
                        [tag.tr(row, class_=deleted and 'trac-deleted' or None)
-                        for deleted, p, row in rows]), class_='props'))
+                        for deleted, spath, row in rows]), class_='props'))
 
     def _get_blocked_revs(self, props, name, path):
         """Return the revisions blocked from merging for the given property
                 pass
         return ""
 
-    def _get_source_link(self, path, context):
+    def _get_source_link(self, spath, context):
         """Return a link to a merge source."""
-        return tag.a(path, title=_('View merge source'),
-                     href=context.href.browser(path,
+        return tag.a('/' + spath, title=_('View merge source'),
+                     href=context.href.browser(spath,
                                                rev=context.resource.version))
 
     def _get_revs_link(self, label, context, spath, revs):
         # Build 3 columns table showing modifications on merge sources
         # || source || added revs || removed revs ||
         # || source || removed                    ||
+        repos = self.env.get_repository()
         def parse_sources(props):
             sources = {}
             for line in props[name].splitlines():
                 path, revs = line.split(':', 1)
-                spath = path.strip('/')
-                sources[spath] = (path, set(Ranges(revs.strip())))
+                spath = _path_within_scope(repos.scope, path)
+                if spath is not None:
+                    sources[spath] = set(Ranges(revs.strip()))
             return sources
         old_sources = parse_sources(old_props)
         new_sources = parse_sources(new_props)
                 revs = to_ranges(revs)
                 return self._get_revs_link(revs.replace(',', u',\u200b'),
                                            context, spath, revs)
-        repos = self.env.get_repository()
         modified_sources = []
-        for spath, (path, new_revs) in new_sources.iteritems():
+        for spath, new_revs in new_sources.iteritems():
             if spath in old_sources:
-                old_revs, status = old_sources.pop(spath)[1], None
+                old_revs, status = old_sources.pop(spath), None
             else:
                 old_revs, status = set(), _(' (added)')
             added = new_revs - old_revs
                 pass
             if added or removed:
                 modified_sources.append((
-                    path, [self._get_source_link(path, new_context), status],
+                    spath, [self._get_source_link(spath, new_context), status],
                     added and tag(added_label, revs_link(added, new_context)),
                     removed and tag(removed_label,
                                     revs_link(removed, old_context))))
         # Go through remaining old sources, those were deleted
         removed_sources = []
         for spath, (path, old_revs) in old_sources.iteritems():
-            removed_sources.append((path,
-                                    self._get_source_link(path, old_context)))
+            removed_sources.append((spath,
+                                    self._get_source_link(spath, old_context)))
         if modified_sources or removed_sources:
             modified_sources.sort()
             removed_sources.sort()
             changes = tag.table(tag.tbody(
                 [tag.tr(tag.td(src), tag.td(added), tag.td(removed))
-                 for p, src, added, removed in modified_sources],
+                 for spath, src, added, removed in modified_sources],
                 [tag.tr(tag.td(src), tag.td(_('removed'), colspan=2))
-                 for p, src in removed_sources]), class_='props')
+                 for spath, src in removed_sources]), class_='props')
         else:
             changes = tag.em(_(' (with no actual effect on merging)'))
         return tag.li(tag('Property ', tag.strong(name), ' changed'),