##// END OF EJS Templates
hgweb: conditionally show file logs for deleted files
Dirkjan Ochtman -
r7300:591767e6 default
parent child Browse files
Show More
@@ -0,0 +1,40 b''
1 hg init test
2 cd test
3
4 echo b > b
5 hg ci -Am "b"
6
7 echo a > a
8 hg ci -Am "first a"
9
10 hg rm a
11 hg ci -m "del a"
12
13 echo b > a
14 hg ci -Am "second a"
15
16 hg rm a
17 hg ci -m "del2 a"
18
19 hg log -p
20
21 hg serve -n test -p $HGPORT -d --pid-file=hg.pid -E errors.log
22 cat hg.pid >> $DAEMON_PIDS
23
24 echo % tip - two revisions
25 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log/tip/a')
26
27 echo % second version - two revisions
28 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log/3/a')
29
30 echo % first deleted - one revision
31 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log/2/a')
32
33 echo % first version - one revision
34 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log/1/a')
35
36 echo % before addition - error
37 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/log/0/a')
38
39 echo % errors
40 cat errors.log
@@ -0,0 +1,418 b''
1 adding b
2 adding a
3 adding a
4 changeset: 4:52e848cdcd88
5 tag: tip
6 user: test
7 date: Thu Jan 01 00:00:00 1970 +0000
8 summary: del2 a
9
10 diff -r 01de2d66a28d -r 52e848cdcd88 a
11 --- a/a Thu Jan 01 00:00:00 1970 +0000
12 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13 @@ -1,1 +0,0 @@
14 -b
15
16 changeset: 3:01de2d66a28d
17 user: test
18 date: Thu Jan 01 00:00:00 1970 +0000
19 summary: second a
20
21 diff -r be3ebcc91739 -r 01de2d66a28d a
22 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23 +++ b/a Thu Jan 01 00:00:00 1970 +0000
24 @@ -0,0 +1,1 @@
25 +b
26
27 changeset: 2:be3ebcc91739
28 user: test
29 date: Thu Jan 01 00:00:00 1970 +0000
30 summary: del a
31
32 diff -r 5ed941583260 -r be3ebcc91739 a
33 --- a/a Thu Jan 01 00:00:00 1970 +0000
34 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35 @@ -1,1 +0,0 @@
36 -a
37
38 changeset: 1:5ed941583260
39 user: test
40 date: Thu Jan 01 00:00:00 1970 +0000
41 summary: first a
42
43 diff -r 6563da9dcf87 -r 5ed941583260 a
44 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45 +++ b/a Thu Jan 01 00:00:00 1970 +0000
46 @@ -0,0 +1,1 @@
47 +a
48
49 changeset: 0:6563da9dcf87
50 user: test
51 date: Thu Jan 01 00:00:00 1970 +0000
52 summary: b
53
54 diff -r 000000000000 -r 6563da9dcf87 b
55 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56 +++ b/b Thu Jan 01 00:00:00 1970 +0000
57 @@ -0,0 +1,1 @@
58 +b
59
60 % tip - two revisions
61 200 Script output follows
62
63 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
64 <html>
65 <head>
66 <link rel="icon" href="/static/hgicon.png" type="image/png">
67 <meta name="robots" content="index, nofollow" />
68 <link rel="stylesheet" href="/static/style.css" type="text/css" />
69
70 <title>test: a history</title>
71 <link rel="alternate" type="application/atom+xml"
72 href="/atom-log/tip/a" title="Atom feed for test:a">
73 <link rel="alternate" type="application/rss+xml"
74 href="/rss-log/tip/a" title="RSS feed for test:a">
75 </head>
76 <body>
77
78 <div class="buttons">
79 <a href="/log">changelog</a>
80 <a href="/shortlog">shortlog</a>
81 <a href="/graph">graph</a>
82 <a href="/tags">tags</a>
83 <a href="/file/01de2d66a28d/a">file</a>
84 <a href="/annotate/01de2d66a28d/a">annotate</a>
85 <a type="application/rss+xml" href="/rss-log/tip/a">rss</a>
86 <a type="application/atom+xml" href="/atom-log/tip/a" title="Atom feed for test:a">atom</a>
87 </div>
88
89 <h2>a revision history</h2>
90
91 <p>navigate: <small class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </small></p>
92
93 <table class="logEntry parity0">
94 <tr>
95 <th class="age">38 years ago:</th>
96 <th class="firstline"><a href="/rev/01de2d66a28d">second a</a></th>
97 </tr>
98 <tr>
99 <th class="revision">revision 1:</td>
100 <td class="node">
101 <a href="/file/01de2d66a28d/a">01de2d66a28d</a>
102 <a href="/diff/01de2d66a28d/a">(diff)</a>
103 <a href="/annotate/01de2d66a28d/a">(annotate)</a>
104 </td>
105 </tr>
106
107 <tr>
108 <th class="author">author:</th>
109 <td class="author">&#116;&#101;&#115;&#116;</td>
110 </tr>
111 <tr>
112 <th class="date">date:</th>
113 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
114 </tr>
115 </table>
116
117
118 <table class="logEntry parity1">
119 <tr>
120 <th class="age">38 years ago:</th>
121 <th class="firstline"><a href="/rev/5ed941583260">first a</a></th>
122 </tr>
123 <tr>
124 <th class="revision">revision 0:</td>
125 <td class="node">
126 <a href="/file/5ed941583260/a">5ed941583260</a>
127 <a href="/diff/5ed941583260/a">(diff)</a>
128 <a href="/annotate/5ed941583260/a">(annotate)</a>
129 </td>
130 </tr>
131
132 <tr>
133 <th class="author">author:</th>
134 <td class="author">&#116;&#101;&#115;&#116;</td>
135 </tr>
136 <tr>
137 <th class="date">date:</th>
138 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
139 </tr>
140 </table>
141
142
143
144
145
146 <div class="logo">
147 <a href="http://www.selenic.com/mercurial/">
148 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
149 </div>
150
151 </body>
152 </html>
153
154 % second version - two revisions
155 200 Script output follows
156
157 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
158 <html>
159 <head>
160 <link rel="icon" href="/static/hgicon.png" type="image/png">
161 <meta name="robots" content="index, nofollow" />
162 <link rel="stylesheet" href="/static/style.css" type="text/css" />
163
164 <title>test: a history</title>
165 <link rel="alternate" type="application/atom+xml"
166 href="/atom-log/tip/a" title="Atom feed for test:a">
167 <link rel="alternate" type="application/rss+xml"
168 href="/rss-log/tip/a" title="RSS feed for test:a">
169 </head>
170 <body>
171
172 <div class="buttons">
173 <a href="/log">changelog</a>
174 <a href="/shortlog">shortlog</a>
175 <a href="/graph">graph</a>
176 <a href="/tags">tags</a>
177 <a href="/file/01de2d66a28d/a">file</a>
178 <a href="/annotate/01de2d66a28d/a">annotate</a>
179 <a type="application/rss+xml" href="/rss-log/tip/a">rss</a>
180 <a type="application/atom+xml" href="/atom-log/tip/a" title="Atom feed for test:a">atom</a>
181 </div>
182
183 <h2>a revision history</h2>
184
185 <p>navigate: <small class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </small></p>
186
187 <table class="logEntry parity0">
188 <tr>
189 <th class="age">38 years ago:</th>
190 <th class="firstline"><a href="/rev/01de2d66a28d">second a</a></th>
191 </tr>
192 <tr>
193 <th class="revision">revision 1:</td>
194 <td class="node">
195 <a href="/file/01de2d66a28d/a">01de2d66a28d</a>
196 <a href="/diff/01de2d66a28d/a">(diff)</a>
197 <a href="/annotate/01de2d66a28d/a">(annotate)</a>
198 </td>
199 </tr>
200
201 <tr>
202 <th class="author">author:</th>
203 <td class="author">&#116;&#101;&#115;&#116;</td>
204 </tr>
205 <tr>
206 <th class="date">date:</th>
207 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
208 </tr>
209 </table>
210
211
212 <table class="logEntry parity1">
213 <tr>
214 <th class="age">38 years ago:</th>
215 <th class="firstline"><a href="/rev/5ed941583260">first a</a></th>
216 </tr>
217 <tr>
218 <th class="revision">revision 0:</td>
219 <td class="node">
220 <a href="/file/5ed941583260/a">5ed941583260</a>
221 <a href="/diff/5ed941583260/a">(diff)</a>
222 <a href="/annotate/5ed941583260/a">(annotate)</a>
223 </td>
224 </tr>
225
226 <tr>
227 <th class="author">author:</th>
228 <td class="author">&#116;&#101;&#115;&#116;</td>
229 </tr>
230 <tr>
231 <th class="date">date:</th>
232 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
233 </tr>
234 </table>
235
236
237
238
239
240 <div class="logo">
241 <a href="http://www.selenic.com/mercurial/">
242 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
243 </div>
244
245 </body>
246 </html>
247
248 % first deleted - one revision
249 200 Script output follows
250
251 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
252 <html>
253 <head>
254 <link rel="icon" href="/static/hgicon.png" type="image/png">
255 <meta name="robots" content="index, nofollow" />
256 <link rel="stylesheet" href="/static/style.css" type="text/css" />
257
258 <title>test: a history</title>
259 <link rel="alternate" type="application/atom+xml"
260 href="/atom-log/tip/a" title="Atom feed for test:a">
261 <link rel="alternate" type="application/rss+xml"
262 href="/rss-log/tip/a" title="RSS feed for test:a">
263 </head>
264 <body>
265
266 <div class="buttons">
267 <a href="/log">changelog</a>
268 <a href="/shortlog">shortlog</a>
269 <a href="/graph">graph</a>
270 <a href="/tags">tags</a>
271 <a href="/file/5ed941583260/a">file</a>
272 <a href="/annotate/5ed941583260/a">annotate</a>
273 <a type="application/rss+xml" href="/rss-log/tip/a">rss</a>
274 <a type="application/atom+xml" href="/atom-log/tip/a" title="Atom feed for test:a">atom</a>
275 </div>
276
277 <h2>a revision history</h2>
278
279 <p>navigate: <small class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </small></p>
280
281 <table class="logEntry parity0">
282 <tr>
283 <th class="age">38 years ago:</th>
284 <th class="firstline"><a href="/rev/5ed941583260">first a</a></th>
285 </tr>
286 <tr>
287 <th class="revision">revision 0:</td>
288 <td class="node">
289 <a href="/file/5ed941583260/a">5ed941583260</a>
290 <a href="/diff/5ed941583260/a">(diff)</a>
291 <a href="/annotate/5ed941583260/a">(annotate)</a>
292 </td>
293 </tr>
294
295 <tr>
296 <th class="author">author:</th>
297 <td class="author">&#116;&#101;&#115;&#116;</td>
298 </tr>
299 <tr>
300 <th class="date">date:</th>
301 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
302 </tr>
303 </table>
304
305
306
307
308
309 <div class="logo">
310 <a href="http://www.selenic.com/mercurial/">
311 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
312 </div>
313
314 </body>
315 </html>
316
317 % first version - one revision
318 200 Script output follows
319
320 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
321 <html>
322 <head>
323 <link rel="icon" href="/static/hgicon.png" type="image/png">
324 <meta name="robots" content="index, nofollow" />
325 <link rel="stylesheet" href="/static/style.css" type="text/css" />
326
327 <title>test: a history</title>
328 <link rel="alternate" type="application/atom+xml"
329 href="/atom-log/tip/a" title="Atom feed for test:a">
330 <link rel="alternate" type="application/rss+xml"
331 href="/rss-log/tip/a" title="RSS feed for test:a">
332 </head>
333 <body>
334
335 <div class="buttons">
336 <a href="/log">changelog</a>
337 <a href="/shortlog">shortlog</a>
338 <a href="/graph">graph</a>
339 <a href="/tags">tags</a>
340 <a href="/file/5ed941583260/a">file</a>
341 <a href="/annotate/5ed941583260/a">annotate</a>
342 <a type="application/rss+xml" href="/rss-log/tip/a">rss</a>
343 <a type="application/atom+xml" href="/atom-log/tip/a" title="Atom feed for test:a">atom</a>
344 </div>
345
346 <h2>a revision history</h2>
347
348 <p>navigate: <small class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </small></p>
349
350 <table class="logEntry parity0">
351 <tr>
352 <th class="age">38 years ago:</th>
353 <th class="firstline"><a href="/rev/5ed941583260">first a</a></th>
354 </tr>
355 <tr>
356 <th class="revision">revision 0:</td>
357 <td class="node">
358 <a href="/file/5ed941583260/a">5ed941583260</a>
359 <a href="/diff/5ed941583260/a">(diff)</a>
360 <a href="/annotate/5ed941583260/a">(annotate)</a>
361 </td>
362 </tr>
363
364 <tr>
365 <th class="author">author:</th>
366 <td class="author">&#116;&#101;&#115;&#116;</td>
367 </tr>
368 <tr>
369 <th class="date">date:</th>
370 <td class="date">Thu Jan 01 00:00:00 1970 +0000</td>
371 </tr>
372 </table>
373
374
375
376
377
378 <div class="logo">
379 <a href="http://www.selenic.com/mercurial/">
380 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
381 </div>
382
383 </body>
384 </html>
385
386 % before addition - error
387 404 Not Found
388
389 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
390 <html>
391 <head>
392 <link rel="icon" href="/static/hgicon.png" type="image/png">
393 <meta name="robots" content="index, nofollow" />
394 <link rel="stylesheet" href="/static/style.css" type="text/css" />
395
396 <title>Mercurial Error</title>
397 </head>
398 <body>
399
400 <h2>Mercurial Error</h2>
401
402 <p>
403 An error occurred while processing your request:
404 </p>
405 <p>
406 a@6563da9dcf87: not found in manifest
407 </p>
408
409
410 <div class="logo">
411 <a href="http://www.selenic.com/mercurial/">
412 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a>
413 </div>
414
415 </body>
416 </html>
417
418 % errors
@@ -500,15 +500,30 b' def annotate(web, req, tmpl):'
500 permissions=fctx.manifest().flags(f))
500 permissions=fctx.manifest().flags(f))
501
501
502 def filelog(web, req, tmpl):
502 def filelog(web, req, tmpl):
503 fctx = webutil.filectx(web.repo, req)
503
504 f = fctx.path()
504 try:
505 fl = fctx.filelog()
505 fctx = webutil.filectx(web.repo, req)
506 count = len(fl)
506 f = fctx.path()
507 fl = fctx.filelog()
508 except revlog.LookupError:
509 f = webutil.cleanpath(web.repo, req.form['file'][0])
510 fl = web.repo.file(f)
511 numrevs = len(fl)
512 if not numrevs: # file doesn't exist at all
513 raise
514 rev = webutil.changectx(web.repo, req).rev()
515 first = fl.linkrev(fl.node(0))
516 if rev < first: # current rev is from before file existed
517 raise
518 frev = numrevs - 1
519 while fl.linkrev(fl.node(frev)) > rev:
520 frev -= 1
521 fctx = web.repo.filectx(f, fl.linkrev(fl.node(frev)))
522
523 count = fctx.filerev() + 1
507 pagelen = web.maxshortchanges
524 pagelen = web.maxshortchanges
508 pos = fctx.filerev()
525 start = max(0, fctx.filerev() - pagelen + 1) # first rev on this page
509 start = max(0, pos - pagelen + 1)
526 end = min(count, start + pagelen) # last rev on this page
510 end = min(count, start + pagelen)
511 pos = end - 1
512 parity = paritygen(web.stripecount, offset=start-end)
527 parity = paritygen(web.stripecount, offset=start-end)
513
528
514 def entries(limit=0, **map):
529 def entries(limit=0, **map):
@@ -535,7 +550,7 b' def filelog(web, req, tmpl):'
535 yield e
550 yield e
536
551
537 nodefunc = lambda x: fctx.filectx(fileid=x)
552 nodefunc = lambda x: fctx.filectx(fileid=x)
538 nav = webutil.revnavgen(pos, pagelen, count, nodefunc)
553 nav = webutil.revnavgen(end - 1, pagelen, count, nodefunc)
539 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav,
554 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav,
540 entries=lambda **x: entries(limit=0, **x),
555 entries=lambda **x: entries(limit=0, **x),
541 latestentry=lambda **x: entries(limit=1, **x))
556 latestentry=lambda **x: entries(limit=1, **x))
General Comments 0
You need to be logged in to leave comments. Login now