Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 46717:913485776542
revlog: introduce v2 format
As documented in [1], this is still tentative and could be subject to change,
but we need to lay down the foundations in order to work on the next abstraction
layers.
[1] https://www.mercurial-scm.org/wiki/RevlogV2Plan
Differential Revision: https://phab.mercurial-scm.org/D9843
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 28 Jan 2021 15:28:57 +0100 |
parents | e9901d01d135 |
children | 3d740058b467 |
line wrap: on
line diff
--- a/mercurial/revlog.py Fri Feb 12 16:13:34 2021 -0800 +++ b/mercurial/revlog.py Thu Jan 28 15:28:57 2021 +0100 @@ -83,6 +83,7 @@ storageutil, stringutil, ) +from .pure import parsers as pureparsers # blanked usage of all the name to prevent pyflakes constraints # We need these name available in the module for extensions. @@ -364,6 +365,25 @@ return p +indexformatv2 = struct.Struct(pureparsers.Index2Mixin.index_format) +indexformatv2_pack = indexformatv2.pack + + +class revlogv2io(object): + def __init__(self): + self.size = indexformatv2.size + + def parseindex(self, data, inline): + index, cache = parsers.parse_index2(data, inline, revlogv2=True) + return index, cache + + def packentry(self, entry, node, version, rev): + p = indexformatv2_pack(*entry) + if rev == 0: + p = versionformat_pack(version) + p[4:] + return p + + NodemapRevlogIO = None if util.safehasattr(parsers, 'parse_index_devel_nodemap'): @@ -650,6 +670,8 @@ self._io = revlogio() if self.version == REVLOGV0: self._io = revlogoldio() + elif fmt == REVLOGV2: + self._io = revlogv2io() elif devel_nodemap: self._io = NodemapRevlogIO() elif use_rust_index: @@ -2337,7 +2359,13 @@ p1r, p2r, node, + 0, + 0, ) + + if self.version & 0xFFFF != REVLOGV2: + e = e[:8] + self.index.append(e) entry = self._io.packentry(e, self.node, self.version, curr)