[PATCH 06 of 11] patch: add filtering by line ranges in diff()

Yuya Nishihara yuya at tcha.org
Fri Feb 24 11:26:42 EST 2017


On Wed, 22 Feb 2017 16:10:00 +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1484921270 -3600
> #      Fri Jan 20 15:07:50 2017 +0100
> # Node ID ddf1b3d89b595aa5b376bb51a8edf458b8f1b1c8
> # Parent  9090c35a37b14e5e09d0911d4794b65ee9ed35de
> # EXP-Topic linerange-log/hgweb-filelog
> patch: add filtering by line ranges in diff()
> 
> We add a "lineranges" parameter to patch.diff() that is mapping from filectx
> to line range tuple (fromline, toline). This is used in getfilectx inner
> function (used in patch.trydiff()) so that the latter returns the line range
> associated with the filectx, if any. Then, in patch.trydiff() we pass this
> information to mdiff.unidiff() where hunks will be filtered accordingly.
> 
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -2214,7 +2214,7 @@ def difffeatureopts(ui, opts=None, untru
>      return mdiff.diffopts(**buildopts)
>  
>  def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,
> -         losedatafn=None, prefix='', relroot='', copy=None):
> +         losedatafn=None, prefix='', relroot='', copy=None, lineranges=None):
>      '''yields diff of changes to files between two nodes, or node and
>      working directory.

This API seems a bit odd, but I have no better idea.

Can you update the function document in V2?


More information about the Mercurial-devel mailing list