diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -570,11 +570,9 @@ m = match.always(repo.root, repo.getcwd()) diffopts = patch.diffopts(repo.ui, untrusted=True) - node1 = basectx.node() - node2 = ctx.node() parity = paritygen(stripecount) - diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts) + diffhunks = patch.diffhunks(repo, basectx, ctx, m, opts=diffopts) for blockno, (fctx1, fctx2, header, hunks) in enumerate(diffhunks, 1): if style != 'raw': header = header[1:] diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2268,8 +2268,14 @@ hunksfilterfn, if not None, should be a function taking a filectx and hunks generator that may yield filtered hunks. ''' + if not node1 and not node2: + node1 = repo.dirstate.p1() + + ctx1 = repo[node1] + ctx2 = repo[node2] + for fctx1, fctx2, hdr, hunks in diffhunks( - repo, node1=node1, node2=node2, + repo, ctx1=ctx1, ctx2=ctx2, match=match, changes=changes, opts=opts, losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy, ): @@ -2286,7 +2292,7 @@ if text: yield text -def diffhunks(repo, node1=None, node2=None, match=None, changes=None, +def diffhunks(repo, ctx1, ctx2, match=None, changes=None, opts=None, losedatafn=None, prefix='', relroot='', copy=None): """Yield diff of changes to files in the form of (`header`, `hunks`) tuples where `header` is a list of diff headers and `hunks` is an iterable of @@ -2298,9 +2304,6 @@ if opts is None: opts = mdiff.defaultopts - if not node1 and not node2: - node1 = repo.dirstate.p1() - def lrugetfilectx(): cache = {} order = collections.deque() @@ -2317,9 +2320,6 @@ return getfilectx getfilectx = lrugetfilectx() - ctx1 = repo[node1] - ctx2 = repo[node2] - if relroot: relrootmatch = scmutil.match(ctx2, pats=[relroot], default='path') match = matchmod.intersectmatchers(match, relrootmatch)