diff mercurial/manifest.py @ 42347:6310180662f5

commit: move sorting of added and removed files list to lower level localrepo.commitctx() has lists of all changed files, as well as lists of added and removed files. The list of all files is unsorted and changelog.add() will sort it. Let's also sort the lists of added and removed files at a lower level (manifestrevlog.add()) for consistency. It also seems safer to do it there, just before we write them to the store. That way other callers won't be able to create invalid commits (or whatever the consequence is) by passing in unsorted lists. Also, alternative storages may not care that the lists are sorted. I don't think this will be a performance problem (someone should have fixed the sorting in changelog.add() if it were). Differential Revision: https://phab.mercurial-scm.org/D6390
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 14 May 2019 16:30:38 -0700
parents 27d6956d386b
children 12bd4e2d4d06
line wrap: on
line diff
--- a/mercurial/manifest.py	Wed Apr 24 09:39:40 2019 -0700
+++ b/mercurial/manifest.py	Tue May 14 16:30:38 2019 -0700
@@ -1486,8 +1486,8 @@
 
             _checkforbidden(added)
             # combine the changed lists into one sorted iterator
-            work = heapq.merge([(x, False) for x in added],
-                               [(x, True) for x in removed])
+            work = heapq.merge([(x, False) for x in sorted(added)],
+                               [(x, True) for x in sorted(removed)])
 
             arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work)
             cachedelta = self._revlog.rev(p1), deltatext