##// END OF EJS Templates
hgweb: extract changeset template mapping generation to own function...
Gregory Szorc -
r24177:f53b7174 default
parent child Browse files
Show More
@@ -431,56 +431,8 b' def changeset(web, req, tmpl):'
431 431 templates related to diffs may all be used to produce the output.
432 432 """
433 433 ctx = webutil.changectx(web.repo, req)
434 basectx = webutil.basechangectx(web.repo, req)
435 if basectx is None:
436 basectx = ctx.p1()
437 showtags = webutil.showtag(web.repo, tmpl, 'changesettag', ctx.node())
438 showbookmarks = webutil.showbookmark(web.repo, tmpl, 'changesetbookmark',
439 ctx.node())
440 showbranch = webutil.nodebranchnodefault(ctx)
441 434
442 files = []
443 parity = paritygen(web.stripecount)
444 for blockno, f in enumerate(ctx.files()):
445 template = f in ctx and 'filenodelink' or 'filenolink'
446 files.append(tmpl(template,
447 node=ctx.hex(), file=f, blockno=blockno + 1,
448 parity=parity.next()))
449
450 style = web.config('web', 'style', 'paper')
451 if 'style' in req.form:
452 style = req.form['style'][0]
453
454 parity = paritygen(web.stripecount)
455 diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, None, parity, style)
456
457 parity = paritygen(web.stripecount)
458 diffstatgen = webutil.diffstatgen(ctx, basectx)
459 diffstat = webutil.diffstat(tmpl, ctx, diffstatgen, parity)
460
461 return tmpl('changeset',
462 diff=diffs,
463 rev=ctx.rev(),
464 node=ctx.hex(),
465 parent=tuple(webutil.parents(ctx)),
466 child=webutil.children(ctx),
467 basenode=basectx.hex(),
468 changesettag=showtags,
469 changesetbookmark=showbookmarks,
470 changesetbranch=showbranch,
471 author=ctx.user(),
472 desc=ctx.description(),
473 extra=ctx.extra(),
474 date=ctx.date(),
475 files=files,
476 diffsummary=lambda **x: webutil.diffsummary(diffstatgen),
477 diffstat=diffstat,
478 archives=web.archivelist(ctx.hex()),
479 tags=webutil.nodetagsdict(web.repo, ctx.node()),
480 bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()),
481 branch=webutil.nodebranchnodefault(ctx),
482 inbranch=webutil.nodeinbranch(web.repo, ctx),
483 branches=webutil.nodebranchdict(web.repo, ctx))
435 return tmpl('changeset', **webutil.changesetentry(web, req, tmpl, ctx))
484 436
485 437 rev = webcommand('rev')(changeset)
486 438
@@ -10,7 +10,7 b' import os, copy'
10 10 from mercurial import match, patch, error, ui, util, pathutil, context
11 11 from mercurial.i18n import _
12 12 from mercurial.node import hex, nullid
13 from common import ErrorResponse
13 from common import ErrorResponse, paritygen
14 14 from common import HTTP_NOT_FOUND
15 15 import difflib
16 16
@@ -279,6 +279,61 b' def changelistentry(web, ctx, tmpl):'
279 279 "branches": nodebranchdict(repo, ctx)
280 280 }
281 281
282 def changesetentry(web, req, tmpl, ctx):
283 '''Obtain a dictionary to be used to render the "changeset" template.'''
284
285 showtags = showtag(web.repo, tmpl, 'changesettag', ctx.node())
286 showbookmarks = showbookmark(web.repo, tmpl, 'changesetbookmark',
287 ctx.node())
288 showbranch = nodebranchnodefault(ctx)
289
290 files = []
291 parity = paritygen(web.stripecount)
292 for blockno, f in enumerate(ctx.files()):
293 template = f in ctx and 'filenodelink' or 'filenolink'
294 files.append(tmpl(template,
295 node=ctx.hex(), file=f, blockno=blockno + 1,
296 parity=parity.next()))
297
298 basectx = basechangectx(web.repo, req)
299 if basectx is None:
300 basectx = ctx.p1()
301
302 style = web.config('web', 'style', 'paper')
303 if 'style' in req.form:
304 style = req.form['style'][0]
305
306 parity = paritygen(web.stripecount)
307 diff = diffs(web.repo, tmpl, ctx, basectx, None, parity, style)
308
309 parity = paritygen(web.stripecount)
310 diffstatsgen = diffstatgen(ctx, basectx)
311 diffstats = diffstat(tmpl, ctx, diffstatsgen, parity)
312
313 return dict(
314 diff=diff,
315 rev=ctx.rev(),
316 node=ctx.hex(),
317 parent=tuple(parents(ctx)),
318 child=children(ctx),
319 basenode=basectx.hex(),
320 changesettag=showtags,
321 changesetbookmark=showbookmarks,
322 changesetbranch=showbranch,
323 author=ctx.user(),
324 desc=ctx.description(),
325 extra=ctx.extra(),
326 date=ctx.date(),
327 files=files,
328 diffsummary=lambda **x: diffsummary(diffstatsgen),
329 diffstat=diffstats,
330 archives=web.archivelist(ctx.hex()),
331 tags=nodetagsdict(web.repo, ctx.node()),
332 bookmarks=nodebookmarksdict(web.repo, ctx.node()),
333 branch=nodebranchnodefault(ctx),
334 inbranch=nodeinbranch(web.repo, ctx),
335 branches=nodebranchdict(web.repo, ctx))
336
282 337 def listfilediffs(tmpl, files, node, max):
283 338 for f in files[:max]:
284 339 yield tmpl('filedifflink', node=hex(node), file=f)
General Comments 0
You need to be logged in to leave comments. Login now