Merge lp:~mnordhoff/loggerhead/relative-links into lp:loggerhead

Proposed by Matt Nordhoff
Status: Merged
Approved by: Martin Albisetti
Approved revision: 419
Merged at revision: 416
Proposed branch: lp:~mnordhoff/loggerhead/relative-links
Merge into: lp:loggerhead
Diff against target: 101 lines (+19/-14)
5 files modified
loggerhead/apps/branch.py (+10/-5)
loggerhead/apps/config.py (+2/-2)
loggerhead/apps/transport.py (+2/-2)
loggerhead/controllers/download_ui.py (+2/-2)
loggerhead/templates/atom.pt (+3/-3)
To merge this branch: bzr merge lp:~mnordhoff/loggerhead/relative-links
Reviewer Review Type Date Requested Status
Martin Albisetti Approve
Review via email: mp+24767@code.launchpad.net

Commit message

Generate relative links where possible (Michael Hudson, Matt Nordhoff)

Description of the change

Quoting https://code.edge.launchpad.net/~mwhudson/loggerhead/relative-links/+merge/15298:

> This branch generates relative links apart from in redirects.

*This* branch fixes the issues I noticed when reviewing that branch many moons ago, namely that absolute links are necessary in some parts of the Atom feed. The original branch fixed one HTTP redirect to be absolute; this branch fixes the rest too.

There may be other issues. I dunno.

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
420. By Matt Nordhoff

NEWS

421. By Matt Nordhoff

Adjust NEWS

Revision history for this message
Robert Collins (lifeless) wrote :

Looks good enough to eat, to me.

Revision history for this message
Glen Mailer (glenjamin) wrote :

This appears to have broken the "To get this branch, use:" part, which i suspect will need to be special cased.

Updating diff...

An updated diff will be available in a few minutes. Reload to see the changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'loggerhead/apps/branch.py'
--- loggerhead/apps/branch.py 2010-04-14 17:54:32 +0000
+++ loggerhead/apps/branch.py 2010-05-05 18:51:27 +0000
@@ -89,10 +89,15 @@
89 if v is not None:89 if v is not None:
90 qs.append('%s=%s' % (k, urllib.quote(v)))90 qs.append('%s=%s' % (k, urllib.quote(v)))
91 qs = '&'.join(qs)91 qs = '&'.join(qs)
92 return request.construct_url(92 path_info = urllib.quote(
93 self._environ, script_name=self._url_base,93 unicode('/'.join(args)).encode('utf-8'), safe='/~:')
94 path_info=unicode('/'.join(args)).encode('utf-8'),94 if qs:
95 querystring=qs)95 path_info += '?' + qs
96 return self._url_base + path_info
97
98 def absolute_url(self, *args, **kw):
99 rel_url = self.url(*args, **kw)
100 return request.resolve_relative_url(rel_url, self._environ)
96101
97 def context_url(self, *args, **kw):102 def context_url(self, *args, **kw):
98 kw = util.get_context(**kw)103 kw = util.get_context(**kw)
@@ -154,7 +159,7 @@
154 path = request.path_info_pop(environ)159 path = request.path_info_pop(environ)
155 if not path:160 if not path:
156 raise httpexceptions.HTTPMovedPermanently(161 raise httpexceptions.HTTPMovedPermanently(
157 self._url_base + '/changes')162 self.absolute_url('/changes'))
158 if path == 'static':163 if path == 'static':
159 return static_app(environ, start_response)164 return static_app(environ, start_response)
160 cls = self.controllers_dict.get(path)165 cls = self.controllers_dict.get(path)
161166
=== modified file 'loggerhead/apps/config.py'
--- loggerhead/apps/config.py 2009-05-13 13:14:04 +0000
+++ loggerhead/apps/config.py 2010-05-05 18:51:27 +0000
@@ -208,8 +208,8 @@
208 environ['SCRIPT_NAME']208 environ['SCRIPT_NAME']
209 segment = path_info_pop(environ)209 segment = path_info_pop(environ)
210 if segment is None:210 if segment is None:
211 raise httpexceptions.HTTPMovedPermanently(211 raise httpexceptions.HTTPMovedPermanently.relative_redirect(
212 environ['SCRIPT_NAME'] + '/')212 environ['SCRIPT_NAME'] + '/', environ)
213 elif segment == '':213 elif segment == '':
214 response = WSGIResponse()214 response = WSGIResponse()
215 self.browse(response)215 self.browse(response)
216216
=== modified file 'loggerhead/apps/transport.py'
--- loggerhead/apps/transport.py 2010-05-04 02:31:07 +0000
+++ loggerhead/apps/transport.py 2010-05-05 18:51:27 +0000
@@ -69,8 +69,8 @@
69 def app_for_non_branch(self, environ):69 def app_for_non_branch(self, environ):
70 segment = path_info_pop(environ)70 segment = path_info_pop(environ)
71 if segment is None:71 if segment is None:
72 raise httpexceptions.HTTPMovedPermanently(72 raise httpexceptions.HTTPMovedPermanently.relative_redirect(
73 environ['SCRIPT_NAME'] + '/')73 environ['SCRIPT_NAME'] + '/', environ)
74 elif segment == '':74 elif segment == '':
75 if self.name:75 if self.name:
76 name = self.name76 name = self.name
7777
=== modified file 'loggerhead/controllers/download_ui.py'
--- loggerhead/controllers/download_ui.py 2010-04-08 01:08:33 +0000
+++ loggerhead/controllers/download_ui.py 2010-05-05 18:51:27 +0000
@@ -44,8 +44,8 @@
44 args.append(arg)44 args.append(arg)
4545
46 if len(args) < 2:46 if len(args) < 2:
47 raise httpexceptions.HTTPMovedPermanently(self._branch.url(47 raise httpexceptions.HTTPMovedPermanently(
48 '../changes'))48 self._branch.absolute_url('../changes'))
4949
50 revid = h.fix_revid(args[0])50 revid = h.fix_revid(args[0])
51 file_id = args[1]51 file_id = args[1]
5252
=== modified file 'loggerhead/templates/atom.pt'
--- loggerhead/templates/atom.pt 2009-06-06 12:23:11 +0000
+++ loggerhead/templates/atom.pt 2010-05-05 18:51:27 +0000
@@ -4,8 +4,8 @@
4 bazaar changes for <tal:branch-name content="branch/friendly_name">branch name</tal:branch-name>4 bazaar changes for <tal:branch-name content="branch/friendly_name">branch name</tal:branch-name>
5 </title>5 </title>
6 <updated tal:content="string:${updated}Z">${updated}</updated>6 <updated tal:content="string:${updated}Z">${updated}</updated>
7 <id tal:content="python:branch.url(['/atom'])">url</id>7 <id tal:content="python:branch.absolute_url(['/atom'])">url</id>
8 <link rel="self" type="application/atom+xml" tal:attributes="href python:branch.url(['/atom'])" />8 <link rel="self" type="application/atom+xml" tal:attributes="href python:branch.absolute_url(['/atom'])" />
9 <link rel="alternate" type="text/html" tal:attributes="href python:branch.url(['/changes'])" />9 <link rel="alternate" type="text/html" tal:attributes="href python:branch.url(['/changes'])" />
1010
11 <entry tal:repeat="entry changes">11 <entry tal:repeat="entry changes">
@@ -16,7 +16,7 @@
16 updated16 updated
17 </updated>17 </updated>
18 <!-- TODO: The feed validator will generate warnings because this is URL-encoded -->18 <!-- TODO: The feed validator will generate warnings because this is URL-encoded -->
19 <id tal:content="python:branch.url(['/revision', entry.revno])">19 <id tal:content="python:branch.absolute_url(['/revision', entry.revno])">
20 ID20 ID
21 </id>21 </id>
22 <author tal:repeat="author entry/authors">22 <author tal:repeat="author entry/authors">

Subscribers

People subscribed via source and target branches