Patchwork patch: allow copy information to be passed in

login
register
mail settings
Submitter Henrik Stuart
Date June 27, 2016, 1:11 p.m.
Message ID <de6b1dadad4feafa702b.1467033083@DESKTOP-HENRIKS.hq.unity3d.com>
Download mbox | patch
Permalink /patch/15635/
State Accepted
Headers show

Comments

Henrik Stuart - June 27, 2016, 1:11 p.m.
# HG changeset patch
# User Henrik Stuart <henriks@unity3d.com>
# Date 1467022278 -7200
#      Mon Jun 27 12:11:18 2016 +0200
# Node ID de6b1dadad4feafa702bf9eef71699d37edd254f
# Parent  b62bce819d0cafcd94e3838e97062b42c9cb13b2
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.
Augie Fackler - June 27, 2016, 4:54 p.m.
Sure, queued

> On Jun 27, 2016, at 9:11 AM, Henrik Stuart <henriks+hg@unity3d.com> wrote:
> 
> # HG changeset patch
> # User Henrik Stuart <henriks@unity3d.com>
> # Date 1467022278 -7200
> #      Mon Jun 27 12:11:18 2016 +0200
> # Node ID de6b1dadad4feafa702bf9eef71699d37edd254f
> # Parent  b62bce819d0cafcd94e3838e97062b42c9cb13b2
> 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.
> 
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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: