# HG changeset patch # User Denis Laxalde # Date 1489414549 -3600 # Node ID aaebc80c9f1daeaf11f16dc7b843b2cb223dc7e2 # Parent 5e6d44511317363a6e90c12fc24e2ecab338911f hgweb: add a 'linerange' parameter to webutil.diffs() This is used to filter out hunks based on their range (with respect to 'node2' for patch.diffhunks() call, i.e. 'ctx' for webutil.diffs()). This is the simplest way to filter diff hunks, here done on server side. Later on, it might be interesting to perform this filtering on client side and expose a "toggle" action to alternate between full and filtered diff. diff -r 5e6d44511317 -r aaebc80c9f1d mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Thu Jan 19 17:41:00 2017 +0100 +++ b/mercurial/hgweb/webutil.py Mon Mar 13 15:15:49 2017 +0100 @@ -434,7 +434,7 @@ if len(files) > max: yield tmpl('fileellipses') -def diffs(web, tmpl, ctx, basectx, files, style): +def diffs(web, tmpl, ctx, basectx, files, style, linerange=None): def prettyprintlines(lines, blockno): for lineno, l in enumerate(lines, 1): @@ -470,6 +470,11 @@ header = header[1:] lines = [h + '\n' for h in header] for hunkrange, hunklines in hunks: + 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): + continue lines.extend(hunklines) if lines: yield tmpl('diffblock', parity=next(parity), blockno=blockno,