[PATCH 3 of 4 v4] diff: pass a diff hunks filter function from changeset_printer to patch.diff()
Yuya Nishihara
yuya at tcha.org
Wed Oct 18 14:00:44 UTC 2017
On Tue, 17 Oct 2017 21:36:59 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1507293917 -7200
> # Fri Oct 06 14:45:17 2017 +0200
> # Node ID 909a69f31ef323ded6fef8dd56fb44dc97f4cd89
> # Parent c73893dd6cfb5693029f5d9dcf1d537197b40a4a
> # EXP-Topic followlines-cli
> diff: pass a diff hunks filter function from changeset_printer to patch.diff()
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -2296,7 +2296,8 @@ def difffeatureopts(ui, opts=None, untru
> return mdiff.diffopts(**pycompat.strkwargs(buildopts))
>
> def diff(repo, node1=None, node2=None, match=None, changes=None,
> - opts=None, losedatafn=None, prefix='', relroot='', copy=None):
> + opts=None, losedatafn=None, prefix='', relroot='', copy=None,
> + hunksfilterfn=None):
> '''yields diff of changes to files between two nodes, or node and
> working directory.
>
> @@ -2318,12 +2319,18 @@ def diff(repo, node1=None, node2=None, m
> patterns that fall outside it will be ignored.
>
> copy, if not empty, should contain mappings {dst at y: src at x} of copy
> - information.'''
> + information.
> +
> + hunksfilterfn, if not None, should be a function taking a filectx and
> + hunks generator that may yield filtered hunks.
> + '''
> for fctx1, fctx2, hdr, hunks in diffhunks(
> repo, node1=node1, node2=node2,
> match=match, changes=changes, opts=opts,
> losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
> ):
> + if hunksfilterfn is not None:
> + hunks = hunksfilterfn(fctx2, hunks)
fctx2 may be None if the content is binary and (probably) f2 is a removed
file. I don't think that's the case now, but can you double check?
More information about the Mercurial-devel
mailing list