# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 2015-04-16 18:31:48
# Node ID a7f8e3584ef3e37c78bfbf9c934e16eea89dabf7
# Parent  4906dc0e038cb4ec1b9fb94df92e100695b90819

diff: pass the diff matcher to the copy logic

This passes the existing diff matcher instance down to the copy logic so copy
tracing can be more efficient when possible and only trace copies for matching
files.

This only actually affects forwardcopies (i.e. Given A<-B<-C<-D, it works for
'hg diff -r B -r D foo.txt', but not for 'hg diff -r D -r B foo.txt') since
backward copies require walking all histories, and not just the individual
file's.

This reduces 'hg diff -r A -r B foo.txt' time from 15s to 1s when A and B have
80,000 files different.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2127,7 +2127,7 @@ def diff(repo, node1=None, node2=None, m
 
     copy = {}
     if opts.git or opts.upgrade:
-        copy = copies.pathcopies(ctx1, ctx2)
+        copy = copies.pathcopies(ctx1, ctx2, match=match)
 
     if relroot is not None:
         if not relfiltered: