Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 15528:a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
splitblock() was added to handle blocks returned by bdiff.blocks() which differ
only by blank lines but are not made only of blank lines. I do not know exactly
how it could happen but mdiff.blocks() threshold behaviour makes me think it
can if those blocks are made of very popular lines mixed with popular blank
lines. If it is proven to be wrong, the function can be dropped.
The first implementation made annotate share diff configuration entries. But it
looks like users will user -w/b for annotate but not for diff, on both the
command line and hgweb. Since the latter cannot use command line entries, we
introduce a new [annotate] section duplicating the diff whitespace options.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 18 Nov 2011 12:04:31 +0100 |
parents | d06b9c55ddab |
children | 917f263eeb26 |
comparison
equal
deleted
inserted
replaced
15527:9926aab3d0b5 | 15528:a84698badf0b |
---|---|
10 from mercurial import error, encoding, archival, templater, templatefilters | 10 from mercurial import error, encoding, archival, templater, templatefilters |
11 from mercurial.node import short, hex | 11 from mercurial.node import short, hex |
12 from mercurial.util import binary | 12 from mercurial.util import binary |
13 from common import paritygen, staticfile, get_contact, ErrorResponse | 13 from common import paritygen, staticfile, get_contact, ErrorResponse |
14 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND | 14 from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND |
15 from mercurial import graphmod | 15 from mercurial import graphmod, patch |
16 from mercurial import help as helpmod | 16 from mercurial import help as helpmod |
17 from mercurial.i18n import _ | 17 from mercurial.i18n import _ |
18 | 18 |
19 # __all__ is populated with the allowed commands. Be sure to add to it if | 19 # __all__ is populated with the allowed commands. Be sure to add to it if |
20 # you're adding a new command, or the new command won't work. | 20 # you're adding a new command, or the new command won't work. |
574 | 574 |
575 def annotate(web, req, tmpl): | 575 def annotate(web, req, tmpl): |
576 fctx = webutil.filectx(web.repo, req) | 576 fctx = webutil.filectx(web.repo, req) |
577 f = fctx.path() | 577 f = fctx.path() |
578 parity = paritygen(web.stripecount) | 578 parity = paritygen(web.stripecount) |
579 diffopts = patch.diffopts(web.repo.ui, untrusted=True, section='annotate') | |
579 | 580 |
580 def annotate(**map): | 581 def annotate(**map): |
581 last = None | 582 last = None |
582 if binary(fctx.data()): | 583 if binary(fctx.data()): |
583 mt = (mimetypes.guess_type(fctx.path())[0] | 584 mt = (mimetypes.guess_type(fctx.path())[0] |
584 or 'application/octet-stream') | 585 or 'application/octet-stream') |
585 lines = enumerate([((fctx.filectx(fctx.filerev()), 1), | 586 lines = enumerate([((fctx.filectx(fctx.filerev()), 1), |
586 '(binary:%s)' % mt)]) | 587 '(binary:%s)' % mt)]) |
587 else: | 588 else: |
588 lines = enumerate(fctx.annotate(follow=True, linenumber=True)) | 589 lines = enumerate(fctx.annotate(follow=True, linenumber=True, |
590 diffopts=diffopts)) | |
589 for lineno, ((f, targetline), l) in lines: | 591 for lineno, ((f, targetline), l) in lines: |
590 fnode = f.filenode() | 592 fnode = f.filenode() |
591 | 593 |
592 if last != fnode: | 594 if last != fnode: |
593 last = fnode | 595 last = fnode |