changeset 51818: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 187d7c859be7
children 6388fd855f66
files mercurial/merge.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Fri Aug 09 22:45:32 2024 +0200
+++ b/mercurial/merge.py	Wed Aug 07 22:05:36 2024 +0200
@@ -521,7 +521,7 @@
     """
     # We mutate the items in the dict during iteration, so iterate
     # over a copy.
-    for f, action in mresult.filemap():
+    for f, action in list(mresult.filemap()):
         if narrowmatch(f):
             pass
         elif not branchmerge:
@@ -662,7 +662,7 @@
         return sum(len(self._actionmapping[a]) for a in actions)
 
     def filemap(self, sort=False):
-        if sorted:
+        if sort:
             for key, val in sorted(self._filemapping.items()):
                 yield key, val
         else: