--- a/hgkeeper.py Sat Mar 21 17:36:51 2020 -0500
+++ b/hgkeeper.py Sat Mar 21 23:56:43 2020 -0500
@@ -2,7 +2,8 @@
-from mercurial import registrar
+from mercurial import extensions, patch, registrar +from mercurial.hgweb import webutil templatefilter = registrar.templatefilter(filters)
@@ -16,11 +17,54 @@
@templatefilter(b'md5', intype=bytes)
- return hexdigest('md5', text)
+ return hexdigest(b'md5', text) @templatefilter(b'sha256', intype=bytes)
- return hexdigest('sha256', text)
+ return hexdigest(b'sha256', text) + ctx = webutil.changectx(web.repo, web.req) + diffopts = patch.diffopts(ui, {b'noprefix', False}) + return patch.diffstatdata(util.iterlines(ctx.diff(basectx, opts=diffopts))) +def _diffstattmplgen(orig, context, ctx, statgen, parity): + stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen) + return (float(i) / maxtotal) * 100 + for filename, adds, removes, isbinary in stats: + template = b'diffstatlink' if filename in files else b'diffstatnolink' + b'removepct': pct(removes), + b'parity': next(parity), + extensions.wrapfunction(webutil, "_diffstattmplgen", _diffstattmplgen)