Mercurial > public > mercurial-scm > hg
diff mercurial/repair.py @ 45871:a985c4fb23ca
transaction: change list of journal entries into a dictionary
The transaction object used to keep a mapping table of path names to
journal entries and a list of journal entries consisting of path and
file offset to truncate on rollback. The offsets are used in three
cases. repair.strip and rollback process all of them in one go, but they
care about the order. For them, it is perfectly reasonable to read the
journal back from disk as both operations already involve at least one
system call per journal entry. The other consumer is the revlog logic
for moving from inline to external data storage. It doesn't care about
the order of the journal and just needs to original offset stored.
Further optimisations are possible here to move the in-memory journal to
a set(), but without memoisation of the original revlog size this could
turn it into O(n^2) behavior in worst case when many revlogs need to
migrated.
Differential Revision: https://phab.mercurial-scm.org/D9277
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Sat, 07 Nov 2020 21:34:09 +0100 |
parents | 63edc384d3b7 |
children | ec73a6a75985 |
line wrap: on
line diff
--- a/mercurial/repair.py Sat Nov 07 19:24:12 2020 +0100 +++ b/mercurial/repair.py Sat Nov 07 21:34:09 2020 +0100 @@ -209,7 +209,7 @@ # transaction and makes assumptions that file storage is # using append-only files. We'll need some kind of storage # API to handle stripping for us. - offset = len(tr._entries) + oldfiles = set(tr._offsetmap.keys()) tr.startgroup() cl.strip(striprev, tr) @@ -219,8 +219,11 @@ repo.file(fn).strip(striprev, tr) tr.endgroup() - for i in pycompat.xrange(offset, len(tr._entries)): - file, troffset = tr._entries[i] + entries = tr.readjournal() + + for file, troffset in entries: + if file in oldfiles: + continue with repo.svfs(file, b'a', checkambig=True) as fp: fp.truncate(troffset) if troffset == 0: