Mercurial > hg
comparison mercurial/copies.py @ 42514:e7c55e24d6bf
copies: avoid reusing the same variable for two different copy dicts
"childcopies" is initally the copies the current changeset to one of
its children and then we reassign it with the copies from the start of
the chain to the child. Let's use different names for these two
things.
Differential Revision: https://phab.mercurial-scm.org/D6564
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 19 Jun 2019 23:14:10 -0700 |
parents | c0b51449bf6b |
children | 8f9cfc8d2ae1 |
comparison
equal
deleted
inserted
replaced
42513:15f04d652b62 | 42514:e7c55e24d6bf |
---|---|
310 if not alwaysmatch: | 310 if not alwaysmatch: |
311 childcopies = {dst: src for dst, src in childcopies.items() | 311 childcopies = {dst: src for dst, src in childcopies.items() |
312 if match(dst)} | 312 if match(dst)} |
313 # Copy the dict only if later iterations will also need it | 313 # Copy the dict only if later iterations will also need it |
314 if i != len(children[r]) - 1: | 314 if i != len(children[r]) - 1: |
315 copies = copies.copy() | 315 newcopies = copies.copy() |
316 else: | |
317 newcopies = copies | |
316 if childcopies: | 318 if childcopies: |
317 childcopies = _chain(copies, childcopies) | 319 newcopies = _chain(newcopies, childcopies) |
318 else: | |
319 childcopies = copies | |
320 for f in childctx.filesremoved(): | 320 for f in childctx.filesremoved(): |
321 if f in childcopies: | 321 if f in newcopies: |
322 del childcopies[f] | 322 del newcopies[f] |
323 heapq.heappush(work, (c, parent, childcopies)) | 323 heapq.heappush(work, (c, parent, newcopies)) |
324 assert False | 324 assert False |
325 | 325 |
326 def _forwardcopies(a, b, match=None): | 326 def _forwardcopies(a, b, match=None): |
327 """find {dst@b: src@a} copy mapping where a is an ancestor of b""" | 327 """find {dst@b: src@a} copy mapping where a is an ancestor of b""" |
328 | 328 |