Handle non-http source urls (closes #1916263)

For svn the checkout and browse URLs are usually separate, so if the source_url is not http(s), don't pretend one can browse the source using it. Ideally we'd have separate checkout and browse attributes for repos but this should do for now.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset5c60417c3b5e
branchstable
phasepublic
hiddenno
parent revision#99e46533fe14 Fix for the fix for #1902356
child revision#29fb86260ba9 Drop obsolete comment
files modified by this revision
views/primary.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1315401436 -7200
# Wed Sep 07 15:17:16 2011 +0200
# Branch stable
# Node ID 5c60417c3b5e4b420418944720cb2f977d18ce0e
# Parent 99e46533fe1498787f769d9500cb49aceb7f970f
Handle non-http source urls (closes #1916263)

For svn the checkout and browse URLs are usually separate, so if the
source_url is not http(s), don't pretend one can browse the source using
it. Ideally we'd have separate checkout and browse attributes for
repos but this should do for now.

diff --git a/views/primary.py b/views/primary.py
@@ -124,18 +124,20 @@
1      __select__ = is_instance('Repository') & score_entity(lambda x: x.source_url)
2 
3      def entity_call(self, entity):
4          w = self.w
5          _ = self._cw._
6 -        w(u'<h3>%s</h3>' % _('Browse source'))
7 -        w(u'<p>%s</p>' % _('You can browse the source code by following <a href="%s">this link</a>.')
8 -          % xml_escape(entity.source_url))
9 +        url_scheme = entity.source_url.split(':')[0]
10 +        if url_scheme.startswith('http'):
11 +            w(u'<h3>%s</h3>' % _('Browse source'))
12 +            w(u'<p>%s</p>' % _('You can browse the source code by following <a href="%s">this link</a>.')
13 +              % xml_escape(entity.source_url))
14          w(u'<h3>%s</h3>' % _('Command-Line Access'))
15          if entity.has_anonymous_access:
16 -            msg = _('Non-members may check out a read-only working copy anonymously over HTTP.')
17 +            msg = _('Non-members may check out a read-only working copy anonymously over %s.') % xml_escape(url_scheme.upper())
18          else:
19 -            msg = _('Members only may check out working copy over HTTP.')
20 +            msg = _('Members only may check out working copy over %s.') % xml_escape(url_scheme.upper())
21          w(u'<p>%s</p>' % msg)
22          w(u'<p>%s</p>' % _('Use this command to check out the latest project source code:'))
23          w(u'<pre>')
24          if entity.type == 'mercurial':
25              w(u'hg clone %s' % xml_escape(entity.source_url))