##// END OF EJS Templates
hgweb: add less/more links to shortlog/filelog nav
Dirkjan Ochtman -
r10246:b9d02695 default
parent child Browse files
Show More
@@ -200,24 +200,32 b' def changelog(web, req, tmpl, shortlog ='
200 200 for e in l:
201 201 yield e
202 202
203 maxchanges = shortlog and web.maxshortchanges or web.maxchanges
203 revcount = shortlog and web.maxshortchanges or web.maxchanges
204 if 'revcount' in req.form:
205 revcount = int(req.form.get('revcount', [revcount])[0])
206 tmpl.defaults['sessionvars']['revcount'] = revcount
207
208 lessvars = copy.copy(tmpl.defaults['sessionvars'])
209 lessvars['revcount'] = revcount / 2
210 morevars = copy.copy(tmpl.defaults['sessionvars'])
211 morevars['revcount'] = revcount * 2
212
204 213 cl = web.repo.changelog
205 214 count = len(cl)
206 215 pos = ctx.rev()
207 start = max(0, pos - maxchanges + 1)
208 end = min(count, start + maxchanges)
216 start = max(0, pos - revcount + 1)
217 end = min(count, start + revcount)
209 218 pos = end - 1
210 219 parity = paritygen(web.stripecount, offset=start-end)
211 220
212 changenav = webutil.revnavgen(pos, maxchanges, count, web.repo.changectx)
221 changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
213 222
214 return tmpl(shortlog and 'shortlog' or 'changelog',
215 changenav=changenav,
216 node=hex(ctx.node()),
217 rev=pos, changesets=count,
223 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
224 node=hex(ctx.node()), rev=pos, changesets=count,
218 225 entries=lambda **x: changelist(limit=0,**x),
219 226 latestentry=lambda **x: changelist(limit=1,**x),
220 archives=web.archivelist("tip"))
227 archives=web.archivelist("tip"), revcount=revcount,
228 morevars=morevars, lessvars=lessvars)
221 229
222 230 def shortlog(web, req, tmpl):
223 231 return changelog(web, req, tmpl, shortlog = True)
@@ -567,10 +575,19 b' def filelog(web, req, tmpl):'
567 575 frev -= 1
568 576 fctx = web.repo.filectx(f, fl.linkrev(frev))
569 577
578 revcount = web.maxshortchanges
579 if 'revcount' in req.form:
580 revcount = int(req.form.get('revcount', [revcount])[0])
581 tmpl.defaults['sessionvars']['revcount'] = revcount
582
583 lessvars = copy.copy(tmpl.defaults['sessionvars'])
584 lessvars['revcount'] = revcount / 2
585 morevars = copy.copy(tmpl.defaults['sessionvars'])
586 morevars['revcount'] = revcount * 2
587
570 588 count = fctx.filerev() + 1
571 pagelen = web.maxshortchanges
572 start = max(0, fctx.filerev() - pagelen + 1) # first rev on this page
573 end = min(count, start + pagelen) # last rev on this page
589 start = max(0, fctx.filerev() - revcount + 1) # first rev on this page
590 end = min(count, start + revcount) # last rev on this page
574 591 parity = paritygen(web.stripecount, offset=start-end)
575 592
576 593 def entries(limit=0, **map):
@@ -602,11 +619,11 b' def filelog(web, req, tmpl):'
602 619 yield e
603 620
604 621 nodefunc = lambda x: fctx.filectx(fileid=x)
605 nav = webutil.revnavgen(end - 1, pagelen, count, nodefunc)
622 nav = webutil.revnavgen(end - 1, revcount, count, nodefunc)
606 623 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav,
607 624 entries=lambda **x: entries(limit=0, **x),
608 latestentry=lambda **x: entries(limit=1, **x))
609
625 latestentry=lambda **x: entries(limit=1, **x),
626 revcount=revcount, morevars=morevars, lessvars=lessvars)
610 627
611 628 def archive(web, req, tmpl):
612 629 type_ = req.form.get('type', [None])[0]
@@ -43,7 +43,10 b''
43 43 files, or words in the commit message</div>
44 44 </form>
45 45
46 <div class="navigate">{nav%filenaventry}</div>
46 <div class="navigate">
47 <a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a>
48 <a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a>
49 | {nav%filenaventry}</div>
47 50
48 51 <table class="bigtable">
49 52 <tr>
@@ -54,6 +57,12 b' files, or words in the commit message</d'
54 57 {entries%filelogentry}
55 58 </table>
56 59
60 <div class="navigate">
61 <a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a>
62 <a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a>
63 | {nav%filenaventry}
64 </div>
65
57 66 </div>
58 67 </div>
59 68
@@ -39,7 +39,11 b''
39 39 files, or words in the commit message</div>
40 40 </form>
41 41
42 <div class="navigate">rev {rev}: {changenav%navshortentry}</div>
42 <div class="navigate">
43 <a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a>
44 <a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a>
45 | rev {rev}: {changenav%navshortentry}
46 </div>
43 47
44 48 <table class="bigtable">
45 49 <tr>
@@ -50,7 +54,12 b' files, or words in the commit message</d'
50 54 {entries%shortlogentry}
51 55 </table>
52 56
53 <div class="navigate">rev {rev}: {changenav%navshortentry}</div>
57 <div class="navigate">
58 <a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a>
59 <a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a>
60 | rev {rev}: {changenav%navshortentry}
61 </div>
62
54 63 </div>
55 64 </div>
56 65
@@ -201,7 +201,11 b' 200 Script output follows'
201 201 files, or words in the commit message</div>
202 202 </form>
203 203
204 <div class="navigate">rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> </div>
204 <div class="navigate">
205 <a href="/shortlog/2?revcount=30">less</a>
206 <a href="/shortlog/2?revcount=120">more</a>
207 | rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a>
208 </div>
205 209
206 210 <table class="bigtable">
207 211 <tr>
@@ -227,7 +231,12 b' files, or words in the commit message</d'
227 231
228 232 </table>
229 233
230 <div class="navigate">rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> </div>
234 <div class="navigate">
235 <a href="/shortlog/2?revcount=30">less</a>
236 <a href="/shortlog/2?revcount=120">more</a>
237 | rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a>
238 </div>
239
231 240 </div>
232 241 </div>
233 242
@@ -47,7 +47,11 b' 200 Script output follows'
47 47 files, or words in the commit message</div>
48 48 </form>
49 49
50 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
50 <div class="navigate">
51 <a href="/shortlog/-1?revcount=30">less</a>
52 <a href="/shortlog/-1?revcount=120">more</a>
53 | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a>
54 </div>
51 55
52 56 <table class="bigtable">
53 57 <tr>
@@ -58,7 +62,12 b' files, or words in the commit message</d'
58 62
59 63 </table>
60 64
61 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
65 <div class="navigate">
66 <a href="/shortlog/-1?revcount=30">less</a>
67 <a href="/shortlog/-1?revcount=120">more</a>
68 | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a>
69 </div>
70
62 71 </div>
63 72 </div>
64 73
@@ -116,7 +125,11 b' 200 Script output follows'
116 125 files, or words in the commit message</div>
117 126 </form>
118 127
119 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
128 <div class="navigate">
129 <a href="/shortlog/-1?revcount=5">less</a>
130 <a href="/shortlog/-1?revcount=20">more</a>
131 | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a>
132 </div>
120 133
121 134 <table class="bigtable">
122 135 <tr>
@@ -127,7 +140,12 b' files, or words in the commit message</d'
127 140
128 141 </table>
129 142
130 <div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div>
143 <div class="navigate">
144 <a href="/shortlog/-1?revcount=5">less</a>
145 <a href="/shortlog/-1?revcount=20">more</a>
146 | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a>
147 </div>
148
131 149 </div>
132 150 </div>
133 151
@@ -139,7 +139,10 b' 200 Script output follows'
139 139 files, or words in the commit message</div>
140 140 </form>
141 141
142 <div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
142 <div class="navigate">
143 <a href="/log/01de2d66a28d/a?revcount=30">less</a>
144 <a href="/log/01de2d66a28d/a?revcount=120">more</a>
145 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
143 146
144 147 <table class="bigtable">
145 148 <tr>
@@ -160,6 +163,12 b' files, or words in the commit message</d'
160 163
161 164 </table>
162 165
166 <div class="navigate">
167 <a href="/log/01de2d66a28d/a?revcount=30">less</a>
168 <a href="/log/01de2d66a28d/a?revcount=120">more</a>
169 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a>
170 </div>
171
163 172 </div>
164 173 </div>
165 174
@@ -222,7 +231,10 b' 200 Script output follows'
222 231 files, or words in the commit message</div>
223 232 </form>
224 233
225 <div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
234 <div class="navigate">
235 <a href="/log/01de2d66a28d/a?revcount=30">less</a>
236 <a href="/log/01de2d66a28d/a?revcount=120">more</a>
237 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
226 238
227 239 <table class="bigtable">
228 240 <tr>
@@ -243,6 +255,12 b' files, or words in the commit message</d'
243 255
244 256 </table>
245 257
258 <div class="navigate">
259 <a href="/log/01de2d66a28d/a?revcount=30">less</a>
260 <a href="/log/01de2d66a28d/a?revcount=120">more</a>
261 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a>
262 </div>
263
246 264 </div>
247 265 </div>
248 266
@@ -305,7 +323,10 b' 200 Script output follows'
305 323 files, or words in the commit message</div>
306 324 </form>
307 325
308 <div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
326 <div class="navigate">
327 <a href="/log/5ed941583260/a?revcount=30">less</a>
328 <a href="/log/5ed941583260/a?revcount=120">more</a>
329 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
309 330
310 331 <table class="bigtable">
311 332 <tr>
@@ -321,6 +342,12 b' files, or words in the commit message</d'
321 342
322 343 </table>
323 344
345 <div class="navigate">
346 <a href="/log/5ed941583260/a?revcount=30">less</a>
347 <a href="/log/5ed941583260/a?revcount=120">more</a>
348 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a>
349 </div>
350
324 351 </div>
325 352 </div>
326 353
@@ -383,7 +410,10 b' 200 Script output follows'
383 410 files, or words in the commit message</div>
384 411 </form>
385 412
386 <div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
413 <div class="navigate">
414 <a href="/log/5ed941583260/a?revcount=30">less</a>
415 <a href="/log/5ed941583260/a?revcount=120">more</a>
416 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div>
387 417
388 418 <table class="bigtable">
389 419 <tr>
@@ -399,6 +429,12 b' files, or words in the commit message</d'
399 429
400 430 </table>
401 431
432 <div class="navigate">
433 <a href="/log/5ed941583260/a?revcount=30">less</a>
434 <a href="/log/5ed941583260/a?revcount=120">more</a>
435 | <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a>
436 </div>
437
402 438 </div>
403 439 </div>
404 440
General Comments 0
You need to be logged in to leave comments. Login now