comparison mercurial/merge.py @ 51814:23116aefe786 stable

merge: sort filemap only if requested by the caller The name `sorted` refers to a built-in function, which is always true, so the else branch of this if statement was dead code. Because, with this fix, the function can iterate over the dict items while yielding values, the dict should not change size while the generator is running. Because of that, it is required to re-introduce code that makes a caller copy the filemap before modification, which was removed in 3c783ff08d40cbaf36eb27ffe1d296718c0f1d77 (that changeset also introduced the filemap() method including the bug that?s being fixed by this changeset).
author Manuel Jacob <me@manueljacob.de>
date Wed, 07 Aug 2024 22:05:36 +0200
parents e60f9168263c
children 454feddab720
comparison
equal deleted inserted replaced
51794:187d7c859be7 51814:23116aefe786
519 Raise an exception if the merge cannot be completed because the repo is 519 Raise an exception if the merge cannot be completed because the repo is
520 narrowed. 520 narrowed.
521 """ 521 """
522 # We mutate the items in the dict during iteration, so iterate 522 # We mutate the items in the dict during iteration, so iterate
523 # over a copy. 523 # over a copy.
524 for f, action in mresult.filemap(): 524 for f, action in list(mresult.filemap()):
525 if narrowmatch(f): 525 if narrowmatch(f):
526 pass 526 pass
527 elif not branchmerge: 527 elif not branchmerge:
528 mresult.removefile(f) # just updating, ignore changes outside clone 528 mresult.removefile(f) # just updating, ignore changes outside clone
529 elif action[0].no_op: 529 elif action[0].no_op:
660 return len(self._filemapping) 660 return len(self._filemapping)
661 661
662 return sum(len(self._actionmapping[a]) for a in actions) 662 return sum(len(self._actionmapping[a]) for a in actions)
663 663
664 def filemap(self, sort=False): 664 def filemap(self, sort=False):
665 if sorted: 665 if sort:
666 for key, val in sorted(self._filemapping.items()): 666 for key, val in sorted(self._filemapping.items()):
667 yield key, val 667 yield key, val
668 else: 668 else:
669 for key, val in self._filemapping.items(): 669 for key, val in self._filemapping.items():
670 yield key, val 670 yield key, val