##// END OF EJS Templates
revlogv2: add a `get_data` helper to grab the next piece of docket...
marmoute -
r48117:53ab13d6 default
parent child Browse files
Show More
@@ -237,19 +237,30 b' def default_docket(revlog, version_heade'
237 237 def parse_docket(revlog, data, use_pending=False):
238 238 """given some docket data return a docket object for the given revlog"""
239 239 header = S_HEADER.unpack(data[: S_HEADER.size])
240 offset = S_HEADER.size
240
241 # this is a mutable closure capture used in `get_data`
242 offset = [S_HEADER.size]
243
244 def get_data(size):
245 """utility closure to access the `size` next bytes"""
246 if offset[0] + size > len(data):
247 # XXX better class
248 msg = b"docket is too short, expected %d got %d"
249 msg %= (offset[0] + size, len(data))
250 raise error.Abort(msg)
251 raw = data[offset[0] : offset[0] + size]
252 offset[0] += size
253 return raw
241 254
242 255 iheader = iter(header)
243 256
244 257 version_header = next(iheader)
245 258
246 259 index_uuid_size = next(iheader)
247 index_uuid = data[offset : offset + index_uuid_size]
248 offset += index_uuid_size
260 index_uuid = get_data(index_uuid_size)
249 261
250 262 data_uuid_size = next(iheader)
251 data_uuid = data[offset : offset + data_uuid_size]
252 offset += data_uuid_size
263 data_uuid = get_data(data_uuid_size)
253 264
254 265 index_size = next(iheader)
255 266
General Comments 0
You need to be logged in to leave comments. Login now