##// END OF EJS Templates
hgweb: convert {diff} to a mappinggenerator with named template...
Yuya Nishihara -
r38007:8cc23a46 default
parent child Browse files
Show More
@@ -537,9 +537,8 b' def _prettyprintdifflines(context, lines'
537 'linenumber': "% 8s" % difflineno,
537 'linenumber': "% 8s" % difflineno,
538 })
538 })
539
539
540 def diffs(web, ctx, basectx, files, style, linerange=None,
540 def _diffsgen(context, repo, ctx, basectx, files, style, stripecount,
541 lineidprefix=''):
541 linerange, lineidprefix):
542 repo = web.repo
543 if files:
542 if files:
544 m = match.exact(repo.root, repo.getcwd(), files)
543 m = match.exact(repo.root, repo.getcwd(), files)
545 else:
544 else:
@@ -548,7 +547,7 b' def diffs(web, ctx, basectx, files, styl'
548 diffopts = patch.diffopts(repo.ui, untrusted=True)
547 diffopts = patch.diffopts(repo.ui, untrusted=True)
549 node1 = basectx.node()
548 node1 = basectx.node()
550 node2 = ctx.node()
549 node2 = ctx.node()
551 parity = paritygen(web.stripecount)
550 parity = paritygen(stripecount)
552
551
553 diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts)
552 diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts)
554 for blockno, (fctx1, fctx2, header, hunks) in enumerate(diffhunks, 1):
553 for blockno, (fctx1, fctx2, header, hunks) in enumerate(diffhunks, 1):
@@ -565,11 +564,16 b' def diffs(web, ctx, basectx, files, styl'
565 l = templateutil.mappedgenerator(_prettyprintdifflines,
564 l = templateutil.mappedgenerator(_prettyprintdifflines,
566 args=(lines, blockno,
565 args=(lines, blockno,
567 lineidprefix))
566 lineidprefix))
568 yield web.tmpl.generate('diffblock', {
567 yield {
569 'parity': next(parity),
568 'parity': next(parity),
570 'blockno': blockno,
569 'blockno': blockno,
571 'lines': l,
570 'lines': l,
572 })
571 }
572
573 def diffs(web, ctx, basectx, files, style, linerange=None, lineidprefix=''):
574 args = (web.repo, ctx, basectx, files, style, web.stripecount,
575 linerange, lineidprefix)
576 return templateutil.mappinggenerator(_diffsgen, args=args, name='diffblock')
573
577
574 def compare(tmpl, context, leftlines, rightlines):
578 def compare(tmpl, context, leftlines, rightlines):
575 '''Generator function that provides side-by-side comparison data.'''
579 '''Generator function that provides side-by-side comparison data.'''
General Comments 0
You need to be logged in to leave comments. Login now