# HG changeset patch # User Jun Wu # Date 1475939434 -3600 # Node ID dd0ff715a82caa9afd0fa999dccca4d967a506a3 # Parent 33e8a5a00007fb12fe4ff6714bfbb81da0456cd7 hgweb: make fctx.annotate a separated function so it could be wrapped This patch moves "fctx.annotate" used by the "annotate" webcommand, along with the diffopts to a separated function which takes a ui and a fctx. So it could be replaced by other implementations which don't want to replace the core "fctx.annotate" directly. diff -r 33e8a5a00007 -r dd0ff715a82c mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Tue Oct 04 20:49:59 2016 +0800 +++ b/mercurial/hgweb/webcommands.py Sat Oct 08 16:10:34 2016 +0100 @@ -31,7 +31,6 @@ encoding, error, graphmod, - patch, revset, scmutil, templatefilters, @@ -861,8 +860,6 @@ fctx = webutil.filectx(web.repo, req) f = fctx.path() parity = paritygen(web.stripecount) - diffopts = patch.difffeatureopts(web.repo.ui, untrusted=True, - section='annotate', whitespace=True) def parents(f): for p in f.parents(): @@ -877,8 +874,8 @@ or 'application/octet-stream') lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)] else: - lines = fctx.annotate(follow=True, linenumber=True, - diffopts=diffopts) + lines = webutil.annotate(fctx, web.repo.ui) + previousrev = None blockparitygen = paritygen(1) for lineno, ((f, targetline), l) in enumerate(lines): diff -r 33e8a5a00007 -r dd0ff715a82c mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Tue Oct 04 20:49:59 2016 +0800 +++ b/mercurial/hgweb/webutil.py Sat Oct 08 16:10:34 2016 +0100 @@ -164,6 +164,11 @@ def __len__(self): return len(self.siblings) +def annotate(fctx, ui): + diffopts = patch.difffeatureopts(ui, untrusted=True, + section='annotate', whitespace=True) + return fctx.annotate(follow=True, linenumber=True, diffopts=diffopts) + def parents(ctx, hide=None): if isinstance(ctx, context.basefilectx): introrev = ctx.introrev()