Edgewall Software

Changes between Initial Version and Version 3 of Ticket #10079


Ignore:
Timestamp:
Jun 4, 2015, 11:56:20 AM (6 years ago)
Author:
Jun Omae
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10079

    • Property Keywords svn:externals added
    • Property Component generalversion control/browser
    • Property Milestoneundecided
  • Ticket #10079 – Description

    initial v3  
    55will be just rendered as
    66* foo
    7 and nothing else. This is pretty annoying, and I have modified my trac to display in that case the complete line from the externals entry, so if you are intrested, here is my _render_externals function (modified against 0.12.2)
     7and nothing else. This is pretty annoying, and I have modified my trac to display in that case the complete line from the externals entry, so if you are intrested, here is my `_render_externals` function (modified against 0.12.2)
    88
    9 {{{#!python
    10     def _render_externals(self, prop):
    11         if not self._externals_map:
    12             for dummykey, value in self.config.options('svn:externals'):
    13                 value = value.split()
    14                 if len(value) != 2:
    15                     self.log.warn("svn:externals entry %s doesn't contain "
    16                             "a space-separated key value pair, skipping.",
    17                             dummykey)
    18                     continue
    19                 key, value = value
    20                 self._externals_map[key] = value.replace('%', '%%') \
    21                                            .replace('$path', '%(path)s') \
    22                                            .replace('$rev', '%(rev)s')
    23         externals = []
    24         for external in prop.splitlines():
    25             elements = external.split()
    26             if not elements:
    27                 continue
    28             localpath, rev, url = elements[0], '', elements[-1]
    29             if localpath.startswith('#'):
    30                 externals.append((external, None, None, None, None,None))
    31                 continue
    32             if len(elements) == 3:
    33                 rev = elements[1]
    34                 rev = rev.replace('-r', '')
    35             # retrieve a matching entry in the externals map
    36             prefix = []
    37             base_url = url
    38             while base_url:
    39                 if base_url in self._externals_map or base_url == u'/':
    40                     break
    41                 base_url, pref = posixpath.split(base_url)
    42                 prefix.append(pref)
    43             href = self._externals_map.get(base_url)
    44             revstr = rev and ' at revision '+rev or ''
    45             if not href and (url.startswith('http://') or
    46                              url.startswith('https://')):
    47                 href = url.replace('%', '%%')
    48             if href:
    49                 remotepath = ''
    50                 if prefix:
    51                     remotepath = posixpath.join(*reversed(prefix))
    52                 externals.append((localpath, revstr, base_url, remotepath,
    53                                   href % {'path': remotepath, 'rev': rev},external))
    54             else:
    55                 externals.append((localpath, revstr, url, None, None,external))
    56         externals_data = []
    57         for localpath, rev, url, remotepath, href, external in externals:
    58             label = localpath
    59             if url is None:
    60                 title = ''
    61             elif href:
    62                 if url:
    63                     url = ' in ' + url
    64                 label += rev + url
    65                 title = ''.join((remotepath, rev, url))
    66             else:
    67                 label = external
    68                 title = _('No svn:externals configured in trac.ini')
    69             externals_data.append((label, href, title))
    70         return tag.ul([tag.li(tag.a(label, href=href, title=title))
    71                        for label, href, title in externals_data])
     9{{{#!diff
     10diff --git a/trac/versioncontrol/svn_prop.py b/trac/versioncontrol/svn_prop.py
     11index 8c77d0c..2b3e906 100644
     12--- a/trac/versioncontrol/svn_prop.py
     13+++ b/trac/versioncontrol/svn_prop.py
     14@@ -71,7 +71,7 @@ class SubversionPropertyRenderer(Component):
     15                 continue
     16             localpath, rev, url = elements[0], '', elements[-1]
     17             if localpath.startswith('#'):
     18-                externals.append((external, None, None, None, None))
     19+                externals.append((external, None, None, None, None, None))
     20                 continue
     21             if len(elements) == 3:
     22                 rev = elements[1]
     23@@ -94,11 +94,13 @@ class SubversionPropertyRenderer(Component):
     24                 if prefix:
     25                     remotepath = posixpath.join(*reversed(prefix))
     26                 externals.append((localpath, revstr, base_url, remotepath,
     27-                                  href % {'path': remotepath, 'rev': rev}))
     28+                                  href % {'path': remotepath, 'rev': rev},
     29+                                  external))
     30             else:
     31-                externals.append((localpath, revstr, url, None, None))
     32+                externals.append((localpath, revstr, url, None, None,
     33+                                  external))
     34         externals_data = []
     35-        for localpath, rev, url, remotepath, href in externals:
     36+        for localpath, rev, url, remotepath, href, external in externals:
     37             label = localpath
     38             if url is None:
     39                 title = ''
     40@@ -108,6 +110,7 @@ class SubversionPropertyRenderer(Component):
     41                 label += rev + url
     42                 title = ''.join((remotepath, rev, url))
     43             else:
     44+                label = external
     45                 title = _('No svn:externals configured in trac.ini')
     46             externals_data.append((label, href, title))
     47         return tag.ul([tag.li(tag.a(label, href=href, title=title))
     48
    7249}}}