[PATCH] hgweb: make fctx.annotate a separated function so it could be wrapped
Jun Wu
quark at fb.com
Sat Oct 8 15:17:13 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1475939434 -3600
# Sat Oct 08 16:10:34 2016 +0100
# Node ID 30141bc03ab8608b04aa717e4dee46046c00f5d6
# Parent cd7276f7ea8308df2c5d8874d335d73247d0f357
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 30141bc03ab8
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 --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -32,5 +32,4 @@ from .. import (
error,
graphmod,
- patch,
revset,
scmutil,
@@ -862,6 +861,4 @@ def annotate(web, req, tmpl):
f = fctx.path()
parity = paritygen(web.stripecount)
- diffopts = patch.difffeatureopts(web.repo.ui, untrusted=True,
- section='annotate', whitespace=True)
def parents(f):
@@ -878,6 +875,6 @@ def annotate(web, req, tmpl):
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)
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -165,4 +165,9 @@ class _siblings(object):
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):
More information about the Mercurial-devel
mailing list