changeset 29422:40d53d4b5925

patch: allow copy information to be passed in When displaying patches from graphical tools where you can browse through individual files, with diff being called separately on each, recomputing the limits of file copy history can become rather expensive on large repositories. Instead, we can compute it once and pass it in for subsequent calls.
author Henrik Stuart <henriks@unity3d.com>
date Mon, 27 Jun 2016 12:11:18 +0200
parents ecbbf4d56ee8
children d2c6f3a948fa
files mercurial/patch.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Thu Jun 23 22:37:17 2016 +0200
+++ b/mercurial/patch.py	Mon Jun 27 12:11:18 2016 +0200
@@ -2184,7 +2184,7 @@
     return mdiff.diffopts(**buildopts)
 
 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,
-         losedatafn=None, prefix='', relroot=''):
+         losedatafn=None, prefix='', relroot='', copy=None):
     '''yields diff of changes to files between two nodes, or node and
     working directory.
 
@@ -2203,7 +2203,10 @@
     display (used for subrepos).
 
     relroot, if not empty, must be normalized with a trailing /. Any match
-    patterns that fall outside it will be ignored.'''
+    patterns that fall outside it will be ignored.
+
+    copy, if not empty, should contain mappings {dst@y: src@x} of copy
+    information.'''
 
     if opts is None:
         opts = mdiff.defaultopts
@@ -2250,9 +2253,10 @@
         hexfunc = short
     revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
 
-    copy = {}
-    if opts.git or opts.upgrade:
-        copy = copies.pathcopies(ctx1, ctx2, match=match)
+    if copy is None:
+        copy = {}
+        if opts.git or opts.upgrade:
+            copy = copies.pathcopies(ctx1, ctx2, match=match)
 
     if relroot is not None:
         if not relfiltered: