D1772: tests: port revlog index code to modern API
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Sat Jan 6 08:26:30 UTC 2018
indygreg updated this revision to Diff 4739.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D1772?vs=4633&id=4739
REVISION DETAIL
https://phab.mercurial-scm.org/D1772
AFFECTED FILES
tests/test-parseindex2.py
CHANGE DETAILS
diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py
--- a/tests/test-parseindex2.py
+++ b/tests/test-parseindex2.py
@@ -13,10 +13,6 @@
nullid,
nullrev,
)
-# no-check-code
-from mercurial.pure import (
- parsers as pureparsers,
-)
from mercurial import (
policy,
)
@@ -45,27 +41,32 @@
cache = (0, data)
while off <= l:
e = struct.unpack(indexformatng, data[off:off + s])
- nodemap[e[7]] = n
+ e = parsers.IndexV1Entry(*e)
+ nodemap[e.node] = n
append(e)
n += 1
- if e[1] < 0:
+ if e.chunklength < 0:
break
- off += e[1] + s
+ off += e.chunklength + s
else:
while off <= l:
e = struct.unpack(indexformatng, data[off:off + s])
- nodemap[e[7]] = n
+ e = parsers.IndexV1Entry(*e)
+ nodemap[e.node] = n
append(e)
n += 1
off += s
- e = list(index[0])
- type = gettype(e[0])
- e[0] = offset_type(0, type)
- index[0] = tuple(e)
+ e = index[0]
+ type = gettype(e.offsetflags)
+
+ index[0] = parsers.IndexV1Entry(offset_type(0, type),
+ e.chunklength, e.rawlength,
+ e.baserev, e.linkrev,
+ e.p1rev, e.p2rev, e.node)
# add the magic null revision at -1
- index.append((0, 0, 0, -1, -1, -1, -1, nullid))
+ index.append(parsers.IndexV1Entry(0, 0, 0, -1, -1, -1, -1, nullid))
return index, cache
@@ -169,21 +170,6 @@
testversionfail(4, makehex(major, minor + 1, micro))
testversionfail(5, "'foo'")
-def index_equal(a, b):
- """Determine if 2 index objects are equal."""
- # Normalize all entries to IndexV1Entry instances.
- def normvalue(x):
- if isinstance(x, pureparsers.IndexV1Entry):
- return x
-
- assert isinstance(x, tuple)
- return pureparsers.IndexV1Entry(*x)
-
- idxa = list(map(normvalue, a[0]))
- idxb = list(map(normvalue, b[0]))
-
- return (idxa, a[1]) == (idxb, b[1])
-
def runtest() :
# Only test the version-detection logic if it is present.
try:
@@ -210,15 +196,15 @@
py_res_2 = py_parseindex(data_non_inlined, False)
c_res_2 = parse_index2(data_non_inlined, False)
- if not index_equal(py_res_1, c_res_1):
+ if py_res_1 != c_res_1:
print("Parse index result (with inlined data) differs!")
- if not index_equal(py_res_2, c_res_2):
+ if py_res_2 != c_res_2:
print("Parse index result (no inlined data) differs!")
ix = parsers.parse_index2(data_inlined, True)[0]
for i, r in enumerate(ix):
- if r[7] == nullid:
+ if r.node == nullid:
i = -1
try:
if ix[r[7]] != i:
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list