##// END OF EJS Templates
revlog: make the index always return the same tuple...
marmoute -
r47913:4292bed8 default
parent child Browse files
Show More
@@ -335,18 +335,17 b' static PyObject *index_get(indexObject *'
335 335 c_node_id = data + 32;
336 336
337 337 if (self->entry_size == v1_entry_size) {
338 return Py_BuildValue(v1_tuple_format, offset_flags, comp_len,
339 uncomp_len, base_rev, link_rev, parent_1,
340 parent_2, c_node_id, self->nodelen);
338 sidedata_offset = 0;
339 sidedata_comp_len = 0;
341 340 } else {
342 341 sidedata_offset = getbe64(data + 64);
343 342 sidedata_comp_len = getbe32(data + 72);
344
345 return Py_BuildValue(v2_tuple_format, offset_flags, comp_len,
346 uncomp_len, base_rev, link_rev, parent_1,
347 parent_2, c_node_id, self->nodelen,
348 sidedata_offset, sidedata_comp_len);
349 343 }
344
345 return Py_BuildValue(v2_tuple_format, offset_flags, comp_len,
346 uncomp_len, base_rev, link_rev, parent_1, parent_2,
347 c_node_id, self->nodelen, sidedata_offset,
348 sidedata_comp_len);
350 349 }
351 350 /*
352 351 * Pack header information in binary
@@ -2769,15 +2768,9 b' static int index_init(indexObject *self,'
2769 2768 self->entry_size = v1_entry_size;
2770 2769 }
2771 2770
2772 if (self->format_version == format_v1) {
2773 self->nullentry =
2774 Py_BuildValue(PY23("iiiiiiis#", "iiiiiiiy#"), 0, 0, 0, -1,
2775 -1, -1, -1, nullid, self->nodelen);
2776 } else {
2777 self->nullentry =
2778 Py_BuildValue(PY23("iiiiiiis#ii", "iiiiiiiy#ii"), 0, 0, 0,
2779 -1, -1, -1, -1, nullid, self->nodelen, 0, 0);
2780 }
2771 self->nullentry =
2772 Py_BuildValue(PY23("iiiiiiis#ii", "iiiiiiiy#ii"), 0, 0, 0, -1, -1,
2773 -1, -1, nullid, self->nodelen, 0, 0);
2781 2774
2782 2775 if (!self->nullentry)
2783 2776 return -1;
@@ -53,7 +53,7 b' class BaseIndexObject(object):'
53 53 # Size of a C long int, platform independent
54 54 int_size = struct.calcsize(b'>i')
55 55 # An empty index entry, used as a default value to be overridden, or nullrev
56 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid)
56 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
57 57
58 58 @util.propertycache
59 59 def entry_size(self):
@@ -122,11 +122,16 b' class BaseIndexObject(object):'
122 122 else:
123 123 index = self._calculate_index(i)
124 124 data = self._data[index : index + self.entry_size]
125 r = self.index_format.unpack(data)
125 r = self._unpack_entry(data)
126 126 if self._lgt and i == 0:
127 127 r = (offset_type(0, gettype(r[0])),) + r[1:]
128 128 return r
129 129
130 def _unpack_entry(self, data):
131 r = self.index_format.unpack(data)
132 r = r + (0, 0)
133 return r
134
130 135 def pack_header(self, header):
131 136 """pack header information as binary"""
132 137 v_fmt = revlog_constants.INDEX_HEADER
@@ -135,7 +140,7 b' class BaseIndexObject(object):'
135 140 def entry_binary(self, rev):
136 141 """return the raw binary string representing a revision"""
137 142 entry = self[rev]
138 p = revlog_constants.INDEX_ENTRY_V1.pack(*entry)
143 p = revlog_constants.INDEX_ENTRY_V1.pack(*entry[:8])
139 144 if rev == 0:
140 145 p = p[revlog_constants.INDEX_HEADER.size :]
141 146 return p
@@ -266,7 +271,6 b' def parse_index2(data, inline, revlogv2='
266 271
267 272 class Index2Mixin(object):
268 273 index_format = revlog_constants.INDEX_ENTRY_V2
269 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
270 274
271 275 def replace_sidedata_info(
272 276 self, i, sidedata_offset, sidedata_length, offset_flags
@@ -292,6 +296,9 b' class Index2Mixin(object):'
292 296 msg = b"cannot rewrite entries outside of this transaction"
293 297 raise KeyError(msg)
294 298
299 def _unpack_entry(self, data):
300 return self.index_format.unpack(data)
301
295 302 def entry_binary(self, rev):
296 303 """return the raw binary string representing a revision"""
297 304 entry = self[rev]
@@ -135,6 +135,8 b' def parse_index_v0(data, inline):'
135 135 nodemap.get(e[4], node.nullrev),
136 136 nodemap.get(e[5], node.nullrev),
137 137 e[6],
138 0, # no side data support
139 0, # no side data support
138 140 )
139 141 index.append(e2)
140 142 nodemap[e[6]] = n
@@ -54,7 +54,18 b' class unionrevlog(revlog.revlog):'
54 54 for rev2 in self.revlog2:
55 55 rev = self.revlog2.index[rev2]
56 56 # rev numbers - in revlog2, very different from self.rev
57 _start, _csize, rsize, base, linkrev, p1rev, p2rev, node = rev
57 (
58 _start,
59 _csize,
60 rsize,
61 base,
62 linkrev,
63 p1rev,
64 p2rev,
65 node,
66 _sdo,
67 _sds,
68 ) = rev
58 69 flags = _start & 0xFFFF
59 70
60 71 if linkmapper is None: # link is to same revlog
@@ -49,6 +49,7 b' def py_parseindex(data, inline):'
49 49 cache = (0, data)
50 50 while off <= l:
51 51 e = struct.unpack(indexformatng, data[off : off + s])
52 e = e + (0, 0)
52 53 nodemap[e[7]] = n
53 54 append(e)
54 55 n += 1
@@ -58,6 +59,7 b' def py_parseindex(data, inline):'
58 59 else:
59 60 while off <= l:
60 61 e = struct.unpack(indexformatng, data[off : off + s])
62 e = e + (0, 0)
61 63 nodemap[e[7]] = n
62 64 append(e)
63 65 n += 1
@@ -240,7 +242,7 b' class parseindex2tests(unittest.TestCase'
240 242 break
241 243
242 244 def testminusone(self):
243 want = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid)
245 want = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
244 246 index, junk = parsers.parse_index2(data_inlined, True)
245 247 got = index[-1]
246 248 self.assertEqual(want, got) # inline data
General Comments 0
You need to be logged in to leave comments. Login now