Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/copies.py Thu Jun 20 10:58:14 2019 -0700 +++ b/mercurial/copies.py Wed Jun 26 05:20:02 2019 -0700 @@ -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()