changeset 44162:baf3fe2977cc

copies: move early return in mergecopies() earlier It wasn't obvious that the early return happened only when there are no copies. That is the case, however, because if `fullcopy` is empty, then so is `copies1` and `copies2`, and then so is `inversecopies1` and `inversecopies2`, and then so is `allsources`, and then so is `copy`, `diverge` and `renamedelete`. By moving the early return earlier, we also avoid calculating the set of added files from the base to each side. Differential Revision: https://phab.mercurial-scm.org/D7975
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 22 Jan 2020 15:20:12 -0800
parents d7622fdec3b5
children 782e0d9c3b74
files mercurial/copies.py tests/test-issue1802.t tests/test-issue522.t tests/test-merge-criss-cross.t tests/test-up-local-change.t
diffstat 5 files changed, 3 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Fri Jan 24 07:00:45 2020 -0800
+++ b/mercurial/copies.py	Wed Jan 22 15:20:12 2020 -0800
@@ -563,6 +563,9 @@
     copies1 = pathcopies(base, c1)
     copies2 = pathcopies(base, c2)
 
+    if not (copies1 or copies2):
+        return {}, {}, {}, {}, {}
+
     inversecopies1 = {}
     inversecopies2 = {}
     for dst, src in copies1.items():
@@ -632,8 +635,6 @@
 
     fullcopy = copies1.copy()
     fullcopy.update(copies2)
-    if not fullcopy:
-        return copy, {}, diverge, renamedelete, {}
 
     if repo.ui.debugflag:
         repo.ui.debug(
--- a/tests/test-issue1802.t	Fri Jan 24 07:00:45 2020 -0800
+++ b/tests/test-issue1802.t	Wed Jan 22 15:20:12 2020 -0800
@@ -52,8 +52,6 @@
 Simulate a Windows merge:
 
   $ hg --config extensions.n=$TESTTMP/noexec.py merge --debug
-    unmatched files in local:
-     b
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: a03b0deabf2b, local: d6fa54f68ae1+, remote: 2d8bcf2dda39
--- a/tests/test-issue522.t	Fri Jan 24 07:00:45 2020 -0800
+++ b/tests/test-issue522.t	Wed Jan 22 15:20:12 2020 -0800
@@ -25,8 +25,6 @@
   $ hg ci -qAm 'add bar'
 
   $ hg merge --debug
-    unmatched files in local:
-     bar
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: bbd179dfa0a7, local: 71766447bdbb+, remote: 4d9e78aaceee
--- a/tests/test-merge-criss-cross.t	Fri Jan 24 07:00:45 2020 -0800
+++ b/tests/test-merge-criss-cross.t	Wed Jan 22 15:20:12 2020 -0800
@@ -410,11 +410,6 @@
   note: merging c0ef19750a22+ and 6ca01f7342b9 using bids from ancestors 11b5b303e36c and 154e6000f54e
   
   calculating bids for ancestor 11b5b303e36c
-    unmatched files in local:
-     d1/a
-     d1/b
-    unmatched files in other:
-     d2/b
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 11b5b303e36c, local: c0ef19750a22+, remote: 6ca01f7342b9
--- a/tests/test-up-local-change.t	Fri Jan 24 07:00:45 2020 -0800
+++ b/tests/test-up-local-change.t	Wed Jan 22 15:20:12 2020 -0800
@@ -40,8 +40,6 @@
   summary:     1
   
   $ hg --debug up
-    unmatched files in other:
-     b
   resolving manifests
    branchmerge: False, force: False, partial: False
    ancestor: c19d34741b0a, local: c19d34741b0a+, remote: 1e71731e6fbb
@@ -91,8 +89,6 @@
   summary:     1
   
   $ hg --debug up
-    unmatched files in other:
-     b
   resolving manifests
    branchmerge: False, force: False, partial: False
    ancestor: c19d34741b0a, local: c19d34741b0a+, remote: 1e71731e6fbb