##// END OF EJS Templates
obsolete: gather all contents related to format version 0 in a single place...
Pierre-Yves David -
r22612:fdfa40ee default
parent child Browse files
Show More
@@ -63,25 +63,8 b' The file starts with a version header:'
63
63
64 - 1 unsigned byte: version number, starting at zero.
64 - 1 unsigned byte: version number, starting at zero.
65
65
66
66 The header is followed by the markers. Marker format depend of the version. See
67 The header is followed by the markers. Each marker is made of:
67 comment associated with each format for details.
68
69 - 1 unsigned byte: number of new changesets "N", can be zero.
70
71 - 1 unsigned 32-bits integer: metadata size "M" in bytes.
72
73 - 1 byte: a bit field. It is reserved for flags used in common
74 obsolete marker operations, to avoid repeated decoding of metadata
75 entries.
76
77 - 20 bytes: obsoleted changeset identifier.
78
79 - N*20 bytes: new changesets identifiers.
80
81 - M bytes: metadata as a sequence of nul-terminated strings. Each
82 string contains a key and a value, separated by a colon ':', without
83 additional encoding. Keys cannot contain '\0' or ':' and values
84 cannot contain '\0'.
85
68
86 """
69 """
87 import struct
70 import struct
@@ -98,13 +81,6 b' from i18n import _'
98 # you have to rely on third party extension extension to enable this.
81 # you have to rely on third party extension extension to enable this.
99 _enabled = False
82 _enabled = False
100
83
101 # data used for parsing and writing
102 _fm0version = 0
103 _fm0fixed = '>BIB20s'
104 _fm0node = '20s'
105 _fm0fsize = struct.calcsize(_fm0fixed)
106 _fm0fnodesize = struct.calcsize(_fm0node)
107
108 ### obsolescence marker flag
84 ### obsolescence marker flag
109
85
110 ## bumpedfix flag
86 ## bumpedfix flag
@@ -137,24 +113,31 b' from i18n import _'
137 # "bumped" here.
113 # "bumped" here.
138 bumpedfix = 1
114 bumpedfix = 1
139
115
140 def _readmarkers(data):
116 ## Parsing and writing of version "0"
141 """Read and enumerate markers from raw data"""
117 #
142 off = 0
118 # The header is followed by the markers. Each marker is made of:
143 diskversion = _unpack('>B', data[off:off + 1])[0]
119 #
144 off += 1
120 # - 1 unsigned byte: number of new changesets "N", can be zero.
145 if diskversion not in formats:
121 #
146 raise util.Abort(_('parsing obsolete marker: unknown version %r')
122 # - 1 unsigned 32-bits integer: metadata size "M" in bytes.
147 % diskversion)
123 #
148 return diskversion, formats[diskversion][0](data, off)
124 # - 1 byte: a bit field. It is reserved for flags used in common
149
125 # obsolete marker operations, to avoid repeated decoding of metadata
150 def encodemarkers(markers, addheader=False, version=_fm0version):
126 # entries.
151 # Kept separate from flushmarkers(), it will be reused for
127 #
152 # markers exchange.
128 # - 20 bytes: obsoleted changeset identifier.
153 encodeone = formats[version][1]
129 #
154 if addheader:
130 # - N*20 bytes: new changesets identifiers.
155 yield _pack('>B', _fm0version)
131 #
156 for marker in markers:
132 # - M bytes: metadata as a sequence of nul-terminated strings. Each
157 yield encodeone(marker)
133 # string contains a key and a value, separated by a colon ':', without
134 # additional encoding. Keys cannot contain '\0' or ':' and values
135 # cannot contain '\0'.
136 _fm0version = 0
137 _fm0fixed = '>BIB20s'
138 _fm0node = '20s'
139 _fm0fsize = struct.calcsize(_fm0fixed)
140 _fm0fnodesize = struct.calcsize(_fm0node)
158
141
159 def _fm0readmarkers(data, off=0):
142 def _fm0readmarkers(data, off=0):
160 # Loop on markers
143 # Loop on markers
@@ -229,6 +212,26 b' def _fm0encodeonemarker(marker):'
229 # <version> -> (decoder, encoder)
212 # <version> -> (decoder, encoder)
230 formats = {0: (_fm0readmarkers, _fm0encodeonemarker)}
213 formats = {0: (_fm0readmarkers, _fm0encodeonemarker)}
231
214
215 def _readmarkers(data):
216 """Read and enumerate markers from raw data"""
217 off = 0
218 diskversion = _unpack('>B', data[off:off + 1])[0]
219 off += 1
220 if diskversion not in formats:
221 raise util.Abort(_('parsing obsolete marker: unknown version %r')
222 % diskversion)
223 return diskversion, formats[diskversion][0](data, off)
224
225 def encodemarkers(markers, addheader=False, version=_fm0version):
226 # Kept separate from flushmarkers(), it will be reused for
227 # markers exchange.
228 encodeone = formats[version][1]
229 if addheader:
230 yield _pack('>B', _fm0version)
231 for marker in markers:
232 yield encodeone(marker)
233
234
232 def encodemeta(meta):
235 def encodemeta(meta):
233 """Return encoded metadata string to string mapping.
236 """Return encoded metadata string to string mapping.
234
237
General Comments 0
You need to be logged in to leave comments. Login now