Mercurial > hg
annotate mercurial/help/internals/revlogs.txt @ 30827:e997e4826459
help: format revlog.txt more closely to result
The rendered text has spaces before each item in the list
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Jan 2017 11:29:06 -0800 |
parents | 9cb0bb0f29f0 |
children | 0b792507ea15 |
rev | line source |
---|---|
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 Revision logs - or *revlogs* - are an append only data structure for |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 storing discrete entries, or *revisions*. They are the primary storage |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 mechanism of repository data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 Revlogs effectively model a directed acyclic graph (DAG). Each node |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 has edges to 1 or 2 *parent* nodes. Each node contains metadata and |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 the raw value for that node. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 Revlogs consist of entries which have metadata and revision data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 Metadata includes the hash of the revision's content, sizes, and |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 links to its *parent* entries. The collective metadata is referred |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 to as the *index* and the revision data is the *data*. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 Revision data is stored as a series of compressed deltas against previous |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 revisions. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 Revlogs are written in an append-only fashion. We never need to rewrite |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 a file to insert nor do we need to remove data. Rolling back in-progress |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 writes can be performed by truncating files. Read locks can be avoided |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 using simple techniques. This means that references to other data in |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 the same revlog *always* refer to a previous entry. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 Revlogs can be modeled as 0-indexed arrays. The first revision is |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 revision #0 and the second is revision #1. The revision -1 is typically |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 used to mean *does not exist* or *not defined*. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 File Format |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
28 =========== |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 A revlog begins with a 32-bit big endian integer holding version info |
28590
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
31 and feature flags. This integer is shared with the first revision |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
32 entry. |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 This integer is logically divided into 2 16-bit shorts. The least |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 significant half of the integer is the format/version short. The other |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 short holds feature flags that dictate behavior of the revlog. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 Only 1 bit of the format/version short is currently used. Remaining |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 bits are reserved for future use. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 The following values for the format/version short are defined: |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 0 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 The original revlog version. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 1 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 RevlogNG (*next generation*). It replaced version 0 when it was |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 implemented in 2006. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 The feature flags short consists of bit flags. Where 0 is the least |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 significant bit, the following bit offsets define flags: |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 0 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 Store revision data inline. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 1 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 Generaldelta encoding. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 2-15 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 Reserved for future use. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 The following header values are common: |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 00 00 00 01 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 RevlogNG |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 00 01 00 01 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 RevlogNG + inline |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
66 00 02 00 01 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 RevlogNG + generaldelta |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 00 03 00 01 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 RevlogNG + inline + generaldelta |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
28590
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
71 Following the 32-bit header is the remainder of the first index entry. |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
72 Following that are remaining *index* data. Inlined revision data is |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
73 possibly located between index entries. More on this layout is described |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
74 below. |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 RevlogNG Format |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
77 =============== |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 RevlogNG (version 1) begins with an index describing the revisions in |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 the revlog. If the ``inline`` flag is set, revision data is stored inline, |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 or between index entries (as opposed to in a separate container). |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 Each index entry is 64 bytes. The byte layout of each entry is as |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 follows, with byte 0 being the first byte (all data stored as big endian): |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 |
28590
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
86 0-3 (4 bytes) (rev 0 only) |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
87 Revlog header |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
88 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 0-5 (6 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 Absolute offset of revision data from beginning of revlog. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
91 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 6-7 (2 bytes) |
30523
726d30a6d89b
censor: flag internal documentation
Remi Chaintron <remi@fb.com>
parents:
30499
diff
changeset
|
93 Bit flags impacting revision behavior. The following bit offsets define: |
30658
c49be208ae34
documentation: better censor flag documentation
Remi Chaintron <remi@fb.com>
parents:
30523
diff
changeset
|
94 0: REVIDX_ISCENSORED revision has censor metadata, must be verified. |
30746
9cb0bb0f29f0
revlog: REVIDX_EXTSTORED flag
Remi Chaintron <remi@fb.com>
parents:
30658
diff
changeset
|
95 1: REVIDX_EXTSTORED revision data is stored externally. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
96 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 8-11 (4 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 Compressed length of revision data / chunk as stored in revlog. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
99 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 12-15 (4 bytes) |
30499
22d05b53b0e8
help: clarify contents of revlog index
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29747
diff
changeset
|
101 Uncompressed length of revision data. This is the size of the full |
22d05b53b0e8
help: clarify contents of revlog index
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29747
diff
changeset
|
102 revision data, not the size of the chunk post decompression. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
103 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 16-19 (4 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 Base or previous revision this revision's delta was produced against. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 -1 means this revision holds full text (as opposed to a delta). |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 For generaldelta repos, this is the previous revision in the delta |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 chain. For non-generaldelta repos, this is the base or first |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 revision in the delta chain. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
110 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 20-23 (4 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 A revision this revision is *linked* to. This allows a revision in |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 one revlog to be forever associated with a revision in another |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 revlog. For example, a file's revlog may point to the changelog |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 revision that introduced it. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
116 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 24-27 (4 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 Revision of 1st parent. -1 indicates no parent. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
119 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 28-31 (4 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 Revision of 2nd parent. -1 indicates no 2nd parent. |
30827
e997e4826459
help: format revlog.txt more closely to result
Martin von Zweigbergk <martinvonz@google.com>
parents:
30746
diff
changeset
|
122 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 32-63 (32 bytes) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 Hash of revision's full text. Currently, SHA-1 is used and only |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
125 the first 20 bytes of this field are used. The rest of the bytes |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 are ignored and should be stored as \0. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 If inline revision data is being stored, the compressed revision data |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 (of length from bytes offset 8-11 from the index entry) immediately |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 follows the index entry. There is no header on the revision data. There |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 is no padding between it and the index entries before and after. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 If revision data is not inline, then raw revision data is stored in a |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 separate byte container. The offsets from bytes 0-5 and the compressed |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 length from bytes 8-11 define how to access this data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 |
28590
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
137 The first 4 bytes of the revlog are shared between the revlog header |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
138 and the 6 byte absolute offset field from the first revlog entry. |
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
139 |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 Delta Chains |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
141 ============ |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 Revision data is encoded as a chain of *chunks*. Each chain begins with |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 the compressed original full text for that revision. Each subsequent |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 *chunk* is a *delta* against the previous revision. We therefore call |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 these chains of chunks/deltas *delta chains*. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 The full text for a revision is reconstructed by loading the original |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 full text for the base revision of a *delta chain* and then applying |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 *deltas* until the target revision is reconstructed. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
152 *Delta chains* are limited in length so lookup time is bound. They are |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 limited to ~2x the length of the revision's data. The linear distance |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 between the base chunk and the final chunk is also limited so the |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 amount of read I/O to load all chunks in the delta chain is bound. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 Deltas and delta chains are either computed against the previous |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 revision in the revlog or another revision (almost certainly one of |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 the parents of the revision). Historically, deltas were computed against |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 the previous revision. The *generaldelta* revlog feature flag (enabled |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 by default in Mercurial 3.7) activates the mode where deltas are |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 computed against an arbitrary revision (almost certainly a parent revision). |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 File Storage |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
165 ============ |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 Revlogs logically consist of an index (metadata of entries) and |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 revision data. This data may be stored together in a single file or in |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 separate files. The mechanism used is indicated by the ``inline`` feature |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 flag on the revlog. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
172 Mercurial's behavior is to use inline storage until a revlog reaches a |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 certain size, at which point it will be converted to non-inline. The |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
174 reason there is a size limit on inline storage is to establish an upper |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
175 bound on how much data must be read to load the index. It would be a waste |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
176 to read tens or hundreds of extra megabytes of data just to access the |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
177 index data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 The actual layout of revlog files on disk is governed by the repository's |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
180 *store format*. Typically, a ``.i`` file represents the index revlog |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
181 (possibly containing inline data) and a ``.d`` file holds the revision data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
182 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
183 Revision Entries |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
184 ================ |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
185 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
186 Revision entries consist of an optional 1 byte header followed by an |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
187 encoding of the revision data. The headers are as follows: |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
188 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 \0 (0x00) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
190 Revision data is the entirety of the entry, including this header. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
191 u (0x75) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
192 Raw revision data follows. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
193 x (0x78) |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
194 zlib (RFC 1950) data. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
195 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
196 The 0x78 value is actually the first byte of the zlib header (CMF byte). |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
197 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
198 Hash Computation |
29747
aba2bb2a6d0f
help: don't try to render a section on sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29094
diff
changeset
|
199 ================ |
27631
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
201 The hash of the revision is stored in the index and is used both as a primary |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
202 key and for data integrity verification. |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 Currently, SHA-1 is the only supported hashing algorithm. To obtain the SHA-1 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 hash of a revision: |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
206 |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 1. Hash the parent nodes |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 2. Hash the fulltext of the revision |
c18292a6ff54
internals: document revlog format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
209 |
28590
b0b9f6b0a777
help: document sharing of revlog header with revision 0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27631
diff
changeset
|
210 The 20 byte node ids of the parents are fed into the hasher in ascending order. |