Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
42346:38d85ec06552 | 42347:6310180662f5 |
---|---|
1484 # manifest up-front, which may save time later for the | 1484 # manifest up-front, which may save time later for the |
1485 # revlog layer. | 1485 # revlog layer. |
1486 | 1486 |
1487 _checkforbidden(added) | 1487 _checkforbidden(added) |
1488 # combine the changed lists into one sorted iterator | 1488 # combine the changed lists into one sorted iterator |
1489 work = heapq.merge([(x, False) for x in added], | 1489 work = heapq.merge([(x, False) for x in sorted(added)], |
1490 [(x, True) for x in removed]) | 1490 [(x, True) for x in sorted(removed)]) |
1491 | 1491 |
1492 arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work) | 1492 arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work) |
1493 cachedelta = self._revlog.rev(p1), deltatext | 1493 cachedelta = self._revlog.rev(p1), deltatext |
1494 text = util.buffer(arraytext) | 1494 text = util.buffer(arraytext) |
1495 n = self._revlog.addrevision(text, transaction, link, p1, p2, | 1495 n = self._revlog.addrevision(text, transaction, link, p1, p2, |