Mercurial > hg-stable
changeset 42369: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 | 38d85ec06552 |
children | de65ae32b82d |
files | mercurial/localrepo.py mercurial/manifest.py |
diffstat | 2 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Apr 24 09:39:40 2019 -0700 +++ b/mercurial/localrepo.py Tue May 14 16:30:38 2019 -0700 @@ -2641,8 +2641,8 @@ raise # update manifest - removed = [f for f in sorted(removed) if f in m1 or f in m2] - drop = [f for f in removed if f in m] + removed = [f for f in removed if f in m1 or f in m2] + drop = sorted([f for f in removed if f in m]) for f in drop: del m[f] files = changed + removed
--- 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