Mercurial > public > mercurial-scm > hg
diff mercurial/context.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 | cff509500a24 |
children | 2a48422e27f6 |
line wrap: on
line diff
--- a/mercurial/context.py Sun Nov 20 19:14:36 2011 +0100 +++ b/mercurial/context.py Fri Nov 18 12:04:31 2011 +0100 @@ -7,7 +7,7 @@ from node import nullid, nullrev, short, hex from i18n import _ -import ancestor, bdiff, error, util, scmutil, subrepo, patch, encoding +import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding import match as matchmod import os, errno, stat @@ -433,7 +433,7 @@ return [filectx(self._repo, self._path, fileid=x, filelog=self._filelog) for x in c] - def annotate(self, follow=False, linenumber=None): + def annotate(self, follow=False, linenumber=None, diffopts=None): '''returns a list of tuples of (ctx, line) for each line in the file, where ctx is the filectx of the node where that line was last changed. @@ -460,8 +460,13 @@ without_linenumber) def pair(parent, child): - for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): - child[0][b1:b2] = parent[0][a1:a2] + blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts, + refine=True) + for (a1, a2, b1, b2), t in blocks: + # Changed blocks ('!') or blocks made only of blank lines ('~') + # belong to the child. + if t == '=': + child[0][b1:b2] = parent[0][a1:a2] return child getlog = util.lrucachefunc(lambda x: self._repo.file(x))