comparison mercurial/copies.py @ 42520:898b36f74f75

copies: document how 'copies' dict instances are reused We avoid copying these instances as much as we can, so it's not obvious what's safe to do with them. This patch tries to explain what is safe and what is not. Differential Revision: https://phab.mercurial-scm.org/D6578
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 26 Jun 2019 05:20:02 -0700
parents 907cef396635
children 4ebbd7c4a3c5
comparison
equal deleted inserted replaced
42519:907cef396635 42520:898b36f74f75
266 266
267 roots = set(children) - set(missingrevs) 267 roots = set(children) - set(missingrevs)
268 # 'work' contains 3-tuples of a (revision number, parent number, copies). 268 # 'work' contains 3-tuples of a (revision number, parent number, copies).
269 # The parent number is only used for knowing which parent the copies dict 269 # The parent number is only used for knowing which parent the copies dict
270 # came from. 270 # came from.
271 # NOTE: To reduce costly copying the 'copies' dicts, we reuse the same
272 # instance for *one* of the child nodes (the last one). Once an instance
273 # has been put on the queue, it is thus no longer safe to modify it.
274 # Conversely, it *is* safe to modify an instance popped off the queue.
271 work = [(r, 1, {}) for r in roots] 275 work = [(r, 1, {}) for r in roots]
272 heapq.heapify(work) 276 heapq.heapify(work)
273 alwaysmatch = match.always() 277 alwaysmatch = match.always()
274 while work: 278 while work:
275 r, i1, copies = heapq.heappop(work) 279 r, i1, copies = heapq.heappop(work)