Mercurial > public > mercurial-scm > hg
comparison mercurial/pure/parsers.py @ 46857:cc65cea90edb
revlog: move the details of revlog "v1" index inside revlog.utils.constants
The revlog module is quite large and this kind of format information would handy
for other module. So let us start to gather this information about the format in
a more appropriate place.
We update various reference to this information to use the new "source of truth"
in the process.
Differential Revision: https://phab.mercurial-scm.org/D10304
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 05 Apr 2021 12:21:01 +0200 |
parents | d4ba4d51f85f |
children | 85e3a630cad9 |
comparison
equal
deleted
inserted
replaced
46856:34e1fa4b548a | 46857:cc65cea90edb |
---|---|
15 pycompat, | 15 pycompat, |
16 util, | 16 util, |
17 ) | 17 ) |
18 | 18 |
19 from ..revlogutils import nodemap as nodemaputil | 19 from ..revlogutils import nodemap as nodemaputil |
20 from ..revlogutils import constants as revlog_constants | |
20 | 21 |
21 stringio = pycompat.bytesio | 22 stringio = pycompat.bytesio |
22 | 23 |
23 | 24 |
24 _pack = struct.pack | 25 _pack = struct.pack |
41 return int(int(offset) << 16 | type) | 42 return int(int(offset) << 16 | type) |
42 | 43 |
43 | 44 |
44 class BaseIndexObject(object): | 45 class BaseIndexObject(object): |
45 # Format of an index entry according to Python's `struct` language | 46 # Format of an index entry according to Python's `struct` language |
46 index_format = b">Qiiiiii20s12x" | 47 index_format = revlog_constants.INDEX_ENTRY_V1.format |
47 # Size of a C unsigned long long int, platform independent | 48 # Size of a C unsigned long long int, platform independent |
48 big_int_size = struct.calcsize(b'>Q') | 49 big_int_size = struct.calcsize(b'>Q') |
49 # Size of a C long int, platform independent | 50 # Size of a C long int, platform independent |
50 int_size = struct.calcsize(b'>i') | 51 int_size = struct.calcsize(b'>i') |
51 # Size of the entire index format | 52 # Size of the entire index format |
52 index_size = struct.calcsize(index_format) | 53 index_size = revlog_constants.INDEX_ENTRY_V1.size |
53 # An empty index entry, used as a default value to be overridden, or nullrev | 54 # An empty index entry, used as a default value to be overridden, or nullrev |
54 null_item = (0, 0, 0, -1, -1, -1, -1, nullid) | 55 null_item = (0, 0, 0, -1, -1, -1, -1, nullid) |
55 | 56 |
56 @property | 57 @property |
57 def nodemap(self): | 58 def nodemap(self): |