[PATCH] hgweb: fix diff hunks filtering by line range in webutil.diffs()
yuya at tcha.org
Thu Mar 30 09:51:09 EDT 2017
On Wed, 29 Mar 2017 15:10:23 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1490782027 -7200
> # Wed Mar 29 12:07:07 2017 +0200
> # Node ID 28297d6c3ae842f4c26f878bf5b107619366fbd5
> # Parent e540846c67e0f838bcdb1db567a57df28d92491c
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> # hg pull http://hg.logilab.org/users/dlaxalde/hg -r 28297d6c3ae8
> # EXP-Topic linerange-log/hgweb-filelog
> hgweb: fix diff hunks filtering by line range in webutil.diffs()
> The previous clause for filter out a diff hunk was too restrictive. We need to
> consider the following cases (assuming linerange=(lb, ub) and the @s2,l2
> previously on the first and last situations were considered.
> In test-hgweb-filelog.t, add a couple of lines at the beginning of file "b" so
> that the line range we will follow does not start at the beginning of file.
> This covers the change in aforementioned diff hunk filter clause.
> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -473,7 +473,7 @@ def diffs(web, tmpl, ctx, basectx, files
> if linerange is not None and hunkrange is not None:
> s1, l1, s2, l2 = hunkrange
> lb, ub = linerange
> - if not (lb <= s2 < ub or lb < s2 + l2 <= ub):
> + if not (lb < s2 +l2 and ub > s2):
Looks correct compared to mdiff.blocksinrange(). Queued, thanks.
Maybe it'll be nice to add a helper (with docstring) that tests if a hunk
range is included in line range.
More information about the Mercurial-devel