Show More
@@ -21,15 +21,15 b' TREE_METADATA_SIZE = 44' | |||||
21 | # * 12 bytes: format marker |
|
21 | # * 12 bytes: format marker | |
22 | # * 32 bytes: node ID of the working directory's first parent |
|
22 | # * 32 bytes: node ID of the working directory's first parent | |
23 | # * 32 bytes: node ID of the working directory's second parent |
|
23 | # * 32 bytes: node ID of the working directory's second parent | |
|
24 | # * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately | |||
24 | # * 4 bytes: big-endian used size of the data file |
|
25 | # * 4 bytes: big-endian used size of the data file | |
25 | # * {TREE_METADATA_SIZE} bytes: tree metadata, parsed separately |
|
|||
26 | # * 1 byte: length of the data file's UUID |
|
26 | # * 1 byte: length of the data file's UUID | |
27 | # * variable: data file's UUID |
|
27 | # * variable: data file's UUID | |
28 | # |
|
28 | # | |
29 | # Node IDs are null-padded if shorter than 32 bytes. |
|
29 | # Node IDs are null-padded if shorter than 32 bytes. | |
30 | # A data file shorter than the specified used size is corrupted (truncated) |
|
30 | # A data file shorter than the specified used size is corrupted (truncated) | |
31 | HEADER = struct.Struct( |
|
31 | HEADER = struct.Struct( | |
32 |
">{}s32s32s |
|
32 | ">{}s32s32s{}sLB".format(len(V2_FORMAT_MARKER), TREE_METADATA_SIZE) | |
33 | ) |
|
33 | ) | |
34 |
|
34 | |||
35 |
|
35 | |||
@@ -51,7 +51,7 b' class DirstateDocket(object):' | |||||
51 | if not data: |
|
51 | if not data: | |
52 | parents = (nodeconstants.nullid, nodeconstants.nullid) |
|
52 | parents = (nodeconstants.nullid, nodeconstants.nullid) | |
53 | return cls(parents, 0, b'', None) |
|
53 | return cls(parents, 0, b'', None) | |
54 |
marker, p1, p2, |
|
54 | marker, p1, p2, meta, data_size, uuid_size = HEADER.unpack_from(data) | |
55 | if marker != V2_FORMAT_MARKER: |
|
55 | if marker != V2_FORMAT_MARKER: | |
56 | raise ValueError("expected dirstate-v2 marker") |
|
56 | raise ValueError("expected dirstate-v2 marker") | |
57 | uuid = data[HEADER.size : HEADER.size + uuid_size] |
|
57 | uuid = data[HEADER.size : HEADER.size + uuid_size] | |
@@ -65,8 +65,8 b' class DirstateDocket(object):' | |||||
65 | V2_FORMAT_MARKER, |
|
65 | V2_FORMAT_MARKER, | |
66 | p1, |
|
66 | p1, | |
67 | p2, |
|
67 | p2, | |
|
68 | self.tree_metadata, | |||
68 | self.data_size, |
|
69 | self.data_size, | |
69 | self.tree_metadata, |
|
|||
70 | len(self.uuid), |
|
70 | len(self.uuid), | |
71 | ) |
|
71 | ) | |
72 | return header + self.uuid |
|
72 | return header + self.uuid |
@@ -67,11 +67,11 b' struct DocketHeader {' | |||||
67 | parent_1: [u8; STORED_NODE_ID_BYTES], |
|
67 | parent_1: [u8; STORED_NODE_ID_BYTES], | |
68 | parent_2: [u8; STORED_NODE_ID_BYTES], |
|
68 | parent_2: [u8; STORED_NODE_ID_BYTES], | |
69 |
|
69 | |||
|
70 | metadata: TreeMetadata, | |||
|
71 | ||||
70 | /// Counted in bytes |
|
72 | /// Counted in bytes | |
71 | data_size: Size, |
|
73 | data_size: Size, | |
72 |
|
74 | |||
73 | metadata: TreeMetadata, |
|
|||
74 |
|
||||
75 | uuid_size: u8, |
|
75 | uuid_size: u8, | |
76 | } |
|
76 | } | |
77 |
|
77 |
General Comments 0
You need to be logged in to leave comments.
Login now