##// END OF EJS Templates
hgweb: fix problems with empty repositories
Dirkjan Ochtman -
r7565:5f162f61 default
parent child Browse files
Show More
@@ -0,0 +1,12 b''
1 #!/bin/sh
2 # Some tests for hgweb in an empty repository
3
4 hg init test
5 cd test
6 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
7 cat hg.pid >> $DAEMON_PIDS
8
9 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/shortlog')
10 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log')
11 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/graph')
12 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file')
@@ -0,0 +1,348 b''
1 200 Script output follows
2
3 <!-- quirksmode -->
4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 <html>
6 <head>
7 <link rel="icon" href="/static/hgicon.png" type="image/png">
8 <meta name="robots" content="index, nofollow" />
9 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
10
11 <title>test: log</title>
12 <link rel="alternate" type="application/atom+xml"
13 href="/atom-log" title="Atom feed for test">
14 <link rel="alternate" type="application/rss+xml"
15 href="/rss-log" title="RSS feed for test">
16 </head>
17 <body>
18
19 <div class="container">
20 <div class="menu">
21 <div class="logo">
22 <a href="http://www.selenic.com/mercurial/">
23 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
24 </div>
25 <ul>
26 <li class="active">log</li>
27 <li><a href="/graph/000000000000">graph</a></li>
28 <li><a href="/tags">tags</a></li>
29 </ul>
30 <ul>
31 <li><a href="/rev/000000000000">changeset</a></li>
32 <li><a href="/file/000000000000">browse</a></li>
33 </ul>
34 <ul>
35
36 </ul>
37 </div>
38
39 <div class="main">
40 <h2><a href="/">test</a></h2>
41 <h3>log</h3>
42
43 <form class="search" action="/log">
44
45 <p><input name="rev" id="search1" type="text" size="30"></p>
46 <span>find changesets by author, revision,
47 files, or words in the commit message</span>
48 </form>
49
50 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
51
52 <table class="bigtable">
53 <tr>
54 <th class="age">age</th>
55 <th class="author">author</th>
56 <th class="description">description</th>
57 </tr>
58
59 </table>
60
61 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
62 </div>
63 </div>
64
65
66
67 </body>
68 </html>
69
70 200 Script output follows
71
72 <!-- quirksmode -->
73 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
74 <html>
75 <head>
76 <link rel="icon" href="/static/hgicon.png" type="image/png">
77 <meta name="robots" content="index, nofollow" />
78 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
79
80 <title>test: log</title>
81 <link rel="alternate" type="application/atom+xml"
82 href="/atom-log" title="Atom feed for test">
83 <link rel="alternate" type="application/rss+xml"
84 href="/rss-log" title="RSS feed for test">
85 </head>
86 <body>
87
88 <div class="container">
89 <div class="menu">
90 <div class="logo">
91 <a href="http://www.selenic.com/mercurial/">
92 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
93 </div>
94 <ul>
95 <li class="active">log</li>
96 <li><a href="/graph/000000000000">graph</a></li>
97 <li><a href="/tags">tags</a></li>
98 </ul>
99 <ul>
100 <li><a href="/rev/000000000000">changeset</a></li>
101 <li><a href="/file/000000000000">browse</a></li>
102 </ul>
103 <ul>
104
105 </ul>
106 </div>
107
108 <div class="main">
109 <h2><a href="/">test</a></h2>
110 <h3>log</h3>
111
112 <form class="search" action="/log">
113
114 <p><input name="rev" id="search1" type="text" size="30"></p>
115 <span>find changesets by author, revision,
116 files, or words in the commit message</span>
117 </form>
118
119 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
120
121 <table class="bigtable">
122 <tr>
123 <th class="age">age</th>
124 <th class="author">author</th>
125 <th class="description">description</th>
126 </tr>
127
128 </table>
129
130 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
131 </div>
132 </div>
133
134
135
136 </body>
137 </html>
138
139 200 Script output follows
140
141 <!-- quirksmode -->
142 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
143 <html>
144 <head>
145 <link rel="icon" href="/static/hgicon.png" type="image/png">
146 <meta name="robots" content="index, nofollow" />
147 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
148
149 <title>test: revision graph</title>
150 <link rel="alternate" type="application/atom+xml"
151 href="/atom-log" title="Atom feed for test: log">
152 <link rel="alternate" type="application/rss+xml"
153 href="/rss-log" title="RSS feed for test: log">
154 <!--[if IE]><script type="text/javascript" src="/static/excanvas.js"></script><![endif]-->
155 </head>
156 <body>
157
158 <div class="container">
159 <div class="menu">
160 <div class="logo">
161 <a href="http://www.selenic.com/mercurial/">
162 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
163 </div>
164 <ul>
165 <li><a href="/shortlog/000000000000">log</a></li>
166 <li class="active">graph</li>
167 <li><a href="/tags">tags</a></li>
168 </ul>
169 <ul>
170 <li><a href="/rev/000000000000">changeset</a></li>
171 <li><a href="/file/000000000000">browse</a></li>
172 </ul>
173 </div>
174
175 <div class="main">
176 <h2><a href="/">test</a></h2>
177 <h3>graph</h3>
178
179 <form class="search" action="/log">
180
181 <p><input name="rev" id="search1" type="text" size="30"></p>
182 <span>find changesets by author, revision,
183 files, or words in the commit message</span>
184 </form>
185
186 <div class="navigate">
187 <a href="/graph/-1?revcount=12">less</a>
188 <a href="/graph/-1?revcount=50">more</a>
189 | rev -1: <a href="/graph/000000000000">(0)</a> <a href="/graph/tip">tip</a>
190 </div>
191
192 <noscript>The revision graph only works with JavaScript-enabled browsers.</noscript>
193
194 <div id="wrapper">
195 <ul id="nodebgs"></ul>
196 <canvas id="graph" width="224" height="12"></canvas>
197 <ul id="graphnodes"></ul>
198 </div>
199
200 <script type="text/javascript" src="/static/graph.js"></script>
201 <script type="text/javascript">
202 <!-- hide script content
203
204 var data = [];
205 var graph = new Graph();
206 graph.scale(39);
207
208 graph.edge = function(x0, y0, x1, y1, color) {
209
210 this.setColor(color, 0.0, 0.65);
211 this.ctx.beginPath();
212 this.ctx.moveTo(x0, y0);
213 this.ctx.lineTo(x1, y1);
214 this.ctx.stroke();
215
216 }
217
218 var revlink = '<li style="_STYLE"><span class="desc">';
219 revlink += '<a href="/rev/_NODEID" title="_NODEID">_DESC</a>';
220 revlink += '</span>_TAGS<span class="info">_DATE ago, by _USER</span></li>';
221
222 graph.vertex = function(x, y, color, parity, cur) {
223
224 this.ctx.beginPath();
225 color = this.setColor(color, 0.25, 0.75);
226 this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
227 this.ctx.fill();
228
229 var bg = '<li class="bg parity' + parity + '"></li>';
230 var left = (this.columns + 1) * this.bg_height;
231 var nstyle = 'padding-left: ' + left + 'px;';
232 var item = revlink.replace(/_STYLE/, nstyle);
233 item = item.replace(/_PARITY/, 'parity' + parity);
234 item = item.replace(/_NODEID/, cur[0]);
235 item = item.replace(/_NODEID/, cur[0]);
236 item = item.replace(/_DESC/, cur[3]);
237 item = item.replace(/_USER/, cur[4]);
238 item = item.replace(/_DATE/, cur[5]);
239
240 var tagspan = '';
241 if (cur[7].length || (cur[6][0] != 'default' || cur[6][1])) {
242 tagspan = '<span class="logtags">';
243 if (cur[6][1]) {
244 tagspan += '<span class="branchhead" title="' + cur[6][0] + '">';
245 tagspan += cur[6][0] + '</span> ';
246 } else if (!cur[6][1] && cur[6][0] != 'default') {
247 tagspan += '<span class="branchname" title="' + cur[6][0] + '">';
248 tagspan += cur[6][0] + '</span> ';
249 }
250 if (cur[7].length) {
251 for (var t in cur[7]) {
252 var tag = cur[7][t];
253 tagspan += '<span class="tag">' + tag + '</span> ';
254 }
255 }
256 tagspan += '</span>';
257 }
258
259 item = item.replace(/_TAGS/, tagspan);
260 return [bg, item];
261
262 }
263
264 graph.render(data);
265
266 // stop hiding script -->
267 </script>
268
269 <div class="navigate">
270 <a href="/graph/-1?revcount=12">less</a>
271 <a href="/graph/-1?revcount=50">more</a>
272 | rev -1: <a href="/graph/000000000000">(0)</a> <a href="/graph/tip">tip</a>
273 </div>
274
275 </div>
276 </div>
277
278
279
280 </body>
281 </html>
282
283 200 Script output follows
284
285 <!-- quirksmode -->
286 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
287 <html>
288 <head>
289 <link rel="icon" href="/static/hgicon.png" type="image/png">
290 <meta name="robots" content="index, nofollow" />
291 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
292
293 <title>test: 000000000000 /</title>
294 </head>
295 <body>
296
297 <div class="container">
298 <div class="menu">
299 <div class="logo">
300 <a href="http://www.selenic.com/mercurial/">
301 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
302 </div>
303 <ul>
304 <li><a href="/shortlog/000000000000">log</a></li>
305 <li><a href="/graph/000000000000">graph</a></li>
306 <li><a href="/tags">tags</a></li>
307 </ul>
308 <ul>
309 <li><a href="/rev/000000000000">changeset</a></li>
310 <li class="active">browse</li>
311 </ul>
312 <ul>
313
314 </ul>
315 </div>
316
317 <div class="main">
318 <h2><a href="/">test</a></h2>
319 <h3>directory / @ -1:000000000000 <span class="tag">tip</span> </h3>
320
321 <form class="search" action="/log">
322
323 <p><input name="rev" id="search1" type="text" size="30"></p>
324 <span>find changesets by author, revision,
325 files, or words in the commit message</span>
326 </form>
327
328 <table class="bigtable">
329 <tr>
330 <th class="name">name</th>
331 <th class="size">size</th>
332 <th class="permissions">permissions</th>
333 </tr>
334 <tr class="fileline parity0">
335 <td class="name"><a href="/file/000000000000/">[up]</a></td>
336 <td class="size"></td>
337 <td class="permissions">drwxr-xr-x</td>
338 </tr>
339
340
341 </table>
342 </div>
343 </div>
344
345
346 </body>
347 </html>
348
@@ -26,6 +26,9 b' def graph(repo, start_rev, stop_rev):'
26 - The changeset date/time
26 - The changeset date/time
27 """
27 """
28
28
29 if start_rev == nullrev and not stop_rev:
30 return
31
29 assert start_rev >= stop_rev
32 assert start_rev >= stop_rev
30 assert stop_rev >= 0
33 assert stop_rev >= 0
31 curr_rev = start_rev
34 curr_rev = start_rev
@@ -292,7 +292,7 b' def manifest(web, req, tmpl):'
292 break
292 break
293 h[None] = None # denotes files present
293 h[None] = None # denotes files present
294
294
295 if not files and not dirs:
295 if mf and not files and not dirs:
296 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
296 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
297
297
298 def filelist(**map):
298 def filelist(**map):
General Comments 0
You need to be logged in to leave comments. Login now