Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webutil.py @ 38057:f0ee627162f4
hgweb: wrap {diffstat} with mappedgenerator
This can't be a mappinggenerator since the associated templates are switched
per item.
We already have webutil.diffstatgen(). That's why the generator function is
named as _diffstattmplgen().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 04 Apr 2018 00:19:37 +0900 |
parents | 5989261a8356 |
children | 6369e21e97ac |
comparison
equal
deleted
inserted
replaced
38056:9aaa74f9eb87 | 38057:f0ee627162f4 |
---|---|
668 | 668 |
669 stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) | 669 stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) |
670 return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % ( | 670 return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % ( |
671 len(stats), addtotal, removetotal) | 671 len(stats), addtotal, removetotal) |
672 | 672 |
673 def diffstat(tmpl, ctx, statgen, parity): | 673 def _diffstattmplgen(context, tmpl, ctx, statgen, parity): |
674 '''Return a diffstat template for each file in the diff.''' | |
675 | |
676 stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) | 674 stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) |
677 files = ctx.files() | 675 files = ctx.files() |
678 | 676 |
679 def pct(i): | 677 def pct(i): |
680 if maxtotal == 0: | 678 if maxtotal == 0: |
694 'addpct': pct(adds), | 692 'addpct': pct(adds), |
695 'removepct': pct(removes), | 693 'removepct': pct(removes), |
696 'parity': next(parity), | 694 'parity': next(parity), |
697 }) | 695 }) |
698 | 696 |
697 def diffstat(tmpl, ctx, statgen, parity): | |
698 '''Return a diffstat template for each file in the diff.''' | |
699 args = (tmpl, ctx, statgen, parity) | |
700 return templateutil.mappedgenerator(_diffstattmplgen, args=args) | |
701 | |
699 class sessionvars(templateutil.wrapped): | 702 class sessionvars(templateutil.wrapped): |
700 def __init__(self, vars, start='?'): | 703 def __init__(self, vars, start='?'): |
701 self._start = start | 704 self._start = start |
702 self._vars = vars | 705 self._vars = vars |
703 | 706 |