Mercurial > hg
comparison tests/test-parseindex2.py @ 47142:4292bed8da7c
revlog: make the index always return the same tuple
It is simpler to manage the diferrence in on disk format in the internal index
code itself and lets the rest of the code always handle the same object.
This will become even more important when the data we store will be entirely
different (for example the changelog does not need the "linkrev" field.
We start with item reading, we will deal with item writing in the next
changesets.
Differential Revision: https://phab.mercurial-scm.org/D10568
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:21:15 +0200 |
parents | d55b71393907 |
children | 47ffc754989a |
comparison
equal
deleted
inserted
replaced
47141:ac72eee94035 | 47142:4292bed8da7c |
---|---|
47 append = index.append | 47 append = index.append |
48 if inline: | 48 if inline: |
49 cache = (0, data) | 49 cache = (0, data) |
50 while off <= l: | 50 while off <= l: |
51 e = struct.unpack(indexformatng, data[off : off + s]) | 51 e = struct.unpack(indexformatng, data[off : off + s]) |
52 e = e + (0, 0) | |
52 nodemap[e[7]] = n | 53 nodemap[e[7]] = n |
53 append(e) | 54 append(e) |
54 n += 1 | 55 n += 1 |
55 if e[1] < 0: | 56 if e[1] < 0: |
56 break | 57 break |
57 off += e[1] + s | 58 off += e[1] + s |
58 else: | 59 else: |
59 while off <= l: | 60 while off <= l: |
60 e = struct.unpack(indexformatng, data[off : off + s]) | 61 e = struct.unpack(indexformatng, data[off : off + s]) |
62 e = e + (0, 0) | |
61 nodemap[e[7]] = n | 63 nodemap[e[7]] = n |
62 append(e) | 64 append(e) |
63 n += 1 | 65 n += 1 |
64 off += s | 66 off += s |
65 | 67 |
238 except TypeError: | 240 except TypeError: |
239 # pure version doesn't support this | 241 # pure version doesn't support this |
240 break | 242 break |
241 | 243 |
242 def testminusone(self): | 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 index, junk = parsers.parse_index2(data_inlined, True) | 246 index, junk = parsers.parse_index2(data_inlined, True) |
245 got = index[-1] | 247 got = index[-1] |
246 self.assertEqual(want, got) # inline data | 248 self.assertEqual(want, got) # inline data |
247 | 249 |
248 index, junk = parsers.parse_index2(data_non_inlined, False) | 250 index, junk = parsers.parse_index2(data_non_inlined, False) |