Patchwork D6578: copies: document how 'copies' dict instances are reused

login
register
mail settings
Submitter phabricator
Date June 26, 2019, 11:33 p.m.
Message ID <0954f884e45cc687a36e1c8fc5abf39b@localhost.localdomain>
Download mbox | patch
Permalink /patch/40684/
State Not Applicable
Headers show

Comments

phabricator - June 26, 2019, 11:33 p.m.
Closed by commit rHG898b36f74f75: copies: document how &#039;copies&#039; dict instances are reused (authored by martinvonz).
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/D6578?vs=15664&id=15667

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6578/new/

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -268,6 +268,10 @@ 
     # 'work' contains 3-tuples of a (revision number, parent number, copies).
     # The parent number is only used for knowing which parent the copies dict
     # came from.
+    # NOTE: To reduce costly copying the 'copies' dicts, we reuse the same
+    # instance for *one* of the child nodes (the last one). Once an instance
+    # has been put on the queue, it is thus no longer safe to modify it.
+    # Conversely, it *is* safe to modify an instance popped off the queue.
     work = [(r, 1, {}) for r in roots]
     heapq.heapify(work)
     alwaysmatch = match.always()