##// END OF EJS Templates
hgweb: fix broken URLs of RSS/Atom feeds (issue1772)...
Yuya Nishihara -
r10674:6d87c20c stable
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 import os, re, time
9 import os, re, time, urlparse
10 10 from mercurial.i18n import _
11 11 from mercurial import ui, hg, util, templater
12 12 from mercurial import error, encoding
@@ -339,5 +339,17 b' class hgwebdir(object):'
339 339 return tmpl
340 340
341 341 def updatereqenv(self, env):
342 def splitnetloc(netloc):
343 if ':' in netloc:
344 return netloc.split(':', 1)
345 else:
346 return (netloc, None)
347
342 348 if self._baseurl is not None:
343 env['SCRIPT_NAME'] = self._baseurl
349 urlcomp = urlparse.urlparse(self._baseurl)
350 host, port = splitnetloc(urlcomp[1])
351 path = urlcomp[2]
352 env['SERVER_NAME'] = host
353 if port:
354 env['SERVER_PORT'] = port
355 env['SCRIPT_NAME'] = path
@@ -51,6 +51,13 b' echo % should succeed'
51 51 echo % should give a 404 - repo is not published
52 52 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/c/file/tip/c?style=raw'
53 53
54 echo % atom-log without basedir
55 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/atom-log' \
56 | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
57
58 echo % rss-log without basedir
59 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/a/rss-log' \
60 | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
54 61
55 62 cat > paths.conf <<EOF
56 63 [paths]
@@ -119,6 +126,28 b' echo % collections: should succeed'
119 126 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/b/file/tip/b?style=raw'
120 127 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/c/file/tip/c?style=raw'
121 128
129 echo % atom-log with basedir /
130 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/atom-log' \
131 | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
132
133 echo % rss-log with basedir /
134 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/rss-log' \
135 | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
136
137 "$TESTDIR/killdaemons.py"
138
139 hg serve --config web.baseurl=http://hg.example.com:8080/foo/ -p $HGPORT2 -d \
140 --pid-file=hg.pid --webdir-conf collections.conf \
141 -A access-collections-2.log -E error-collections-2.log
142 cat hg.pid >> $DAEMON_PIDS
143
144 echo % atom-log with basedir /foo/
145 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/atom-log' \
146 | grep '<link' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
147
148 echo % rss-log with basedir /foo/
149 "$TESTDIR/get-with-headers.py" localhost:$HGPORT2 '/a/rss-log' \
150 | grep '<guid' | sed 's|//[.a-zA-Z0-9\-_]*:[0-9][0-9]*/|//example.com:8080/|'
122 151
123 152 echo % paths errors 1
124 153 cat error-paths-1.log
@@ -128,3 +157,5 b' echo % paths errors 3'
128 157 cat error-paths-3.log
129 158 echo % collections errors
130 159 cat error-collections.log
160 echo % collections errors 2
161 cat error-collections-2.log
@@ -25,6 +25,12 b' 404 Not Found'
25 25
26 26
27 27 error: repository c not found
28 % atom-log without basedir
29 <link rel="self" href="http://example.com:8080/a/atom-log"/>
30 <link rel="alternate" href="http://example.com:8080/a/"/>
31 <link href="http://example.com:8080/a/rev/8580ff50825a"/>
32 % rss-log without basedir
33 <guid isPermaLink="true">http://example.com:8080/a/rev/8580ff50825a</guid>
28 34 % should succeed, slashy names
29 35 200 Script output follows
30 36
@@ -323,10 +329,10 b' 200 Script output follows'
323 329 200 Script output follows
324 330
325 331
326 http://hg.example.com:8080/a/
327 http://hg.example.com:8080/a/.hg/patches/
328 http://hg.example.com:8080/b/
329 http://hg.example.com:8080/c/
332 /a/
333 /a/.hg/patches/
334 /b/
335 /c/
330 336
331 337 200 Script output follows
332 338
@@ -337,7 +343,20 b' b'
337 343 200 Script output follows
338 344
339 345 c
346 % atom-log with basedir /
347 <link rel="self" href="http://example.com:8080/a/atom-log"/>
348 <link rel="alternate" href="http://example.com:8080/a/"/>
349 <link href="http://example.com:8080/a/rev/8580ff50825a"/>
350 % rss-log with basedir /
351 <guid isPermaLink="true">http://example.com:8080/a/rev/8580ff50825a</guid>
352 % atom-log with basedir /foo/
353 <link rel="self" href="http://example.com:8080/foo/a/atom-log"/>
354 <link rel="alternate" href="http://example.com:8080/foo/a/"/>
355 <link href="http://example.com:8080/foo/a/rev/8580ff50825a"/>
356 % rss-log with basedir /foo/
357 <guid isPermaLink="true">http://example.com:8080/foo/a/rev/8580ff50825a</guid>
340 358 % paths errors 1
341 359 % paths errors 2
342 360 % paths errors 3
343 361 % collections errors
362 % collections errors 2
General Comments 0
You need to be logged in to leave comments. Login now