Mercurial > public > mercurial-scm > hg
comparison mercurial/dirstateutils/docket.py @ 48221:a32a96079e2d
dirstate-v2: initial Python parser
The dirstate-v2 file format should be supported even if Rust extensions are
not enabled. This changeset adds parsing code that is not used yet.
Differential Revision: https://phab.mercurial-scm.org/D11518
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Sun, 03 Oct 2021 13:18:03 +0200 |
parents | d467e44f71d7 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48220:e7b5e8ba7cab | 48221:a32a96079e2d |
---|---|
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import struct | 10 import struct |
11 | 11 |
12 from ..revlogutils import docket as docket_mod | 12 from ..revlogutils import docket as docket_mod |
13 | 13 from . import v2 |
14 | 14 |
15 V2_FORMAT_MARKER = b"dirstate-v2\n" | 15 V2_FORMAT_MARKER = b"dirstate-v2\n" |
16 | |
17 # Must match the constant of the same name in | |
18 # `rust/hg-core/src/dirstate_tree/on_disk.rs` | |
19 TREE_METADATA_SIZE = 44 | |
20 | 16 |
21 # * 12 bytes: format marker | 17 # * 12 bytes: format marker |
22 # * 32 bytes: node ID of the working directory's first parent | 18 # * 32 bytes: node ID of the working directory's first parent |
23 # * 32 bytes: node ID of the working directory's second parent | 19 # * 32 bytes: node ID of the working directory's second parent |
24 # * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately | 20 # * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately |
27 # * variable: data file's UUID | 23 # * variable: data file's UUID |
28 # | 24 # |
29 # Node IDs are null-padded if shorter than 32 bytes. | 25 # Node IDs are null-padded if shorter than 32 bytes. |
30 # A data file shorter than the specified used size is corrupted (truncated) | 26 # A data file shorter than the specified used size is corrupted (truncated) |
31 HEADER = struct.Struct( | 27 HEADER = struct.Struct( |
32 ">{}s32s32s{}sLB".format(len(V2_FORMAT_MARKER), TREE_METADATA_SIZE) | 28 ">{}s32s32s{}sLB".format(len(V2_FORMAT_MARKER), v2.TREE_METADATA_SIZE) |
33 ) | 29 ) |
34 | 30 |
35 | 31 |
36 class DirstateDocket(object): | 32 class DirstateDocket(object): |
37 data_filename_pattern = b'dirstate.%s' | 33 data_filename_pattern = b'dirstate.%s' |