Patchwork D7975: copies: move early return in mergecopies() earlier

login
register
mail settings
Submitter phabricator
Date Jan. 23, 2020, 6:44 a.m.
Message ID <differential-rev-PHID-DREV-wzc4ak72xmkcyewhk5jm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44586/
State Superseded
Headers show

Comments

phabricator - Jan. 23, 2020, 6:44 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7975

AFFECTED FILES
  mercurial/copies.py
  tests/test-issue1802.t
  tests/test-issue522.t
  tests/test-merge-criss-cross.t
  tests/test-up-local-change.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-up-local-change.t b/tests/test-up-local-change.t
--- a/tests/test-up-local-change.t
+++ b/tests/test-up-local-change.t
@@ -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
diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -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
diff --git a/tests/test-issue522.t b/tests/test-issue522.t
--- a/tests/test-issue522.t
+++ b/tests/test-issue522.t
@@ -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
diff --git a/tests/test-issue1802.t b/tests/test-issue1802.t
--- a/tests/test-issue1802.t
+++ b/tests/test-issue1802.t
@@ -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
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -560,6 +560,9 @@ 
     copies1 = pathcopies(base, c1)
     copies2 = pathcopies(base, c2)
 
+    if not (copies1 or copies2):
+        return {}, {}, {}, {}, {}
+
     inversecopies1 = {}
     inversecopies2 = {}
     for dst, src in copies1.items():
@@ -629,8 +632,6 @@ 
 
     fullcopy = copies1.copy()
     fullcopy.update(copies2)
-    if not fullcopy:
-        return copy, {}, diverge, renamedelete, {}
 
     if repo.ui.debugflag:
         repo.ui.debug(