From patchwork Sat Oct 19 17:38:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7124: copies: move from a copy on branchpoint to a copy on write approach From: phabricator X-Patchwork-Id: 42506 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 19 Oct 2019 17:38:20 +0000 Closed by commit rHGffd04bc9f57d: copies: move from a copy on branchpoint to a copy on write approach (authored by marmoute). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7124?vs=17331&id=17361 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7124/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7124 AFFECTED FILES mercurial/copies.py CHANGE DETAILS To: marmoute, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -270,15 +270,19 @@ childcopies = { dst: src for dst, src in childcopies.items() if match(dst) } - # Copy the dict only if later iterations will also need it - if i != len(children[r]) - 1: - newcopies = copies.copy() - else: - newcopies = copies + newcopies = copies if childcopies: newcopies = _chain(newcopies, childcopies) + # _chain makes a copies, we can avoid doing so in some + # simple/linear cases. + assert newcopies is not copies for f in removed: if f in newcopies: + if newcopies is copies: + # copy on write to avoid affecting potential other + # branches. when there are no other branches, this + # could be avoided. + newcopies = copies.copy() del newcopies[f] othercopies = all_copies.get(c) if othercopies is None: