Patchwork D9419: copies: properly copies parent dictionary before updating it

login
register
mail settings
Submitter phabricator
Date Nov. 27, 2020, 4:12 p.m.
Message ID <differential-rev-PHID-DREV-ezrp3cqnb4neyq26x2q6-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47698/
State Superseded
Headers show

Comments

phabricator - Nov. 27, 2020, 4:12 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This enforces the copy on write logic. Otherwise independant unrelated branches
  could affected each other.
  
  More testing of these case are coming, but I need that code landed to unlock
  other performance work in parallel.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -405,9 +405,14 @@ 
                 # changeset based copies. It was made without regards with
                 # potential filelog related behavior.
                 if parent == 1:
+                    if newcopies is copies:
+                        newcopies = copies.copy()
                     minor, major = othercopies, newcopies
                 else:
-                    minor, major = newcopies, othercopies
+                    # we do not know if the other dict is a copy or not, so we
+                    # need to blindly copy it. Future change should make this
+                    # unnecessary.
+                    minor, major = newcopies, othercopies.copy()
                 copies = _merge_copies_dict(minor, major, isancestor, changes)
                 all_copies[c] = copies