##// END OF EJS Templates
interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs...
interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs This is the same transformation as b455dfddfed0 did for dirstate.

File last commit:

r52596:ca7bde5d default
r53366:2aada52e default
Show More
test-revlog-raw.py
528 lines | 16.3 KiB | text/x-python | PythonLexer
/ tests / test-revlog-raw.py
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # test revlog interaction about raw data (flagprocessor)
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 import hashlib
Jun Wu
revlog: add a stronger test for raw processing...
r31748 import sys
from mercurial import (
encoding,
revlog,
transaction,
vfs,
)
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 from mercurial.revlogutils import (
revlog: introduce an explicit tracking of what the revlog is about...
r47838 constants,
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 deltas,
flagutil: move addflagprocessor to the new module (API)
r42958 flagutil,
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 )
revlog: introduce a mandatory `_writing` context to update revlog content...
r47988
Gregory Szorc
py3: use class X: instead of class X(object):...
r49801 class _NoTransaction:
revlog: introduce a mandatory `_writing` context to update revlog content...
r47988 """transaction like object to update the nodemap outside a transaction"""
def __init__(self):
self._postclose = {}
def addpostclose(self, callback_id, callback_func):
self._postclose[callback_id] = callback_func
def registertmp(self, *args, **kwargs):
pass
def addbackup(self, *args, **kwargs):
pass
def add(self, *args, **kwargs):
pass
def addabort(self, *args, **kwargs):
pass
def _report(self, *args):
pass
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # TESTTMP is optional. This makes it convenient to run without run-tests.py
Augie Fackler
tests: port test-revlog-raw.py to Python 3...
r37913 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
Jun Wu
revlog: add a stronger test for raw processing...
r31748
# Enable generaldelta otherwise revlog won't use delta as expected by the test
Augie Fackler
formatting: blacken the codebase...
r43346 tvfs.options = {
b'generaldelta': True,
b'revlogv1': True,
revlog: skip opener options to pass sparse_revlog value...
r51936 b'delta-config': revlog.DeltaConfig(sparse_revlog=True),
Augie Fackler
formatting: blacken the codebase...
r43346 }
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def abort(msg):
print('abort: %s' % msg)
# Return 0 so run-tests.py could compare the output.
sys.exit()
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # Register a revlog processor for flag EXTSTORED.
#
# It simply prepends a fixed header, and replaces '1' to 'i'. So it has
# insertion and replacement, and may be interesting to test revlog's line-based
# deltas.
_extheader = b'E\n'
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def readprocessor(self, rawtext):
# True: the returned text could be used to verify hash
Augie Fackler
formatting: blacken the codebase...
r43346 text = rawtext[len(_extheader) :].replace(b'i', b'1')
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 return text, True
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Augie Fackler
formatting: blacken the codebase...
r43346
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 def writeprocessor(self, text):
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # False: the returned rawtext shouldn't be used to verify hash
rawtext = _extheader + text.replace(b'1', b'i')
return rawtext, False
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def rawprocessor(self, rawtext):
# False: do not verify hash. Only the content returned by "readprocessor"
# can be used to verify hash.
return False
Augie Fackler
formatting: blacken the codebase...
r43346
flagutil.addflagprocessor(
revlog.REVIDX_EXTSTORED, (readprocessor, writeprocessor, rawprocessor)
)
Jun Wu
revlog: add a stronger test for raw processing...
r31748
# Utilities about reading and appending revlog
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def newtransaction():
# A transaction is required to write revlogs
report = lambda msg: None
return transaction.transaction(report, tvfs, {'plain': tvfs}, b'journal')
Augie Fackler
formatting: blacken the codebase...
r43346
revlog: use a "radix" to address revlog...
r47921 def newrevlog(name=b'_testrevlog', recreate=False):
Jun Wu
revlog: add a stronger test for raw processing...
r31748 if recreate:
revlog: use a "radix" to address revlog...
r47921 tvfs.tryunlink(name + b'.i')
target = (constants.KIND_OTHER, b'test')
rlog = revlog.revlog(tvfs, target=target, radix=name)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 return rlog
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def appendrev(rlog, text, tr, isext=False, isdelta=True):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Append a revision. If isext is True, set the EXTSTORED flag so flag
Jun Wu
revlog: add a stronger test for raw processing...
r31748 processor will be used (and rawtext is different from text). If isdelta is
True, force the revision to be a delta, otherwise it's full text.
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Jun Wu
revlog: add a stronger test for raw processing...
r31748 nextrev = len(rlog)
p1 = rlog.node(nextrev - 1)
Joerg Sonnenberger
node: replace nullid and friends with nodeconstants class...
r47771 p2 = rlog.nullid
Jun Wu
revlog: add a stronger test for raw processing...
r31748 if isext:
flags = revlog.REVIDX_EXTSTORED
else:
flags = revlog.REVIDX_DEFAULT_FLAGS
# Change storedeltachains temporarily, to override revlog's delta decision
Gregory Szorc
repository: remove storedeltachains from ifilestorage...
r39268 rlog._storedeltachains = isdelta
Jun Wu
revlog: add a stronger test for raw processing...
r31748 try:
rlog.addrevision(text, tr, nextrev, p1, p2, flags=flags)
return nextrev
except Exception as ex:
abort('rev %d: failed to append: %s' % (nextrev, ex))
finally:
# Restore storedeltachains. It is always True, see revlog.__init__
Gregory Szorc
repository: remove storedeltachains from ifilestorage...
r39268 rlog._storedeltachains = True
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Augie Fackler
formatting: blacken the codebase...
r43346
revlog: use a "radix" to address revlog...
r47921 def addgroupcopy(rlog, tr, destname=b'_destrevlog', optimaldelta=True):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Copy revlog to destname using revlog.addgroup. Return the copied revlog.
Jun Wu
revlog: add a stronger test for raw processing...
r31748
This emulates push or pull. They use changegroup. Changegroup requires
repo to work. We don't have a repo, so a dummy changegroup is used.
If optimaldelta is True, use optimized delta parent, so the destination
revlog could probably reuse it. Otherwise it builds sub-optimal delta, and
the destination revlog needs more work to use it.
This exercises some revlog.addgroup (and revlog._addrevision(text=None))
code path, which is not covered by "appendrev" alone.
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
py3: use class X: instead of class X(object):...
r49801 class dummychangegroup:
Jun Wu
revlog: add a stronger test for raw processing...
r31748 @staticmethod
def deltachunk(pnode):
Joerg Sonnenberger
node: replace nullid and friends with nodeconstants class...
r47771 pnode = pnode or rlog.nullid
Jun Wu
revlog: add a stronger test for raw processing...
r31748 parentrev = rlog.rev(pnode)
r = parentrev + 1
if r >= len(rlog):
return {}
if optimaldelta:
deltaparent = parentrev
else:
# suboptimal deltaparent
deltaparent = min(0, parentrev)
revlog: make the `candelta` method private...
r51897 if not rlog._candelta(deltaparent, r):
Jun Wu
revlog: do not use delta for lfs revisions...
r36765 deltaparent = -1
Augie Fackler
formatting: blacken the codebase...
r43346 return {
b'node': rlog.node(r),
b'p1': pnode,
Joerg Sonnenberger
node: replace nullid and friends with nodeconstants class...
r47771 b'p2': rlog.nullid,
Augie Fackler
formatting: blacken the codebase...
r43346 b'cs': rlog.node(rlog.linkrev(r)),
b'flags': rlog.flags(r),
b'deltabase': rlog.node(deltaparent),
b'delta': rlog.revdiff(deltaparent, r),
Raphaël Gomès
changegroup: add v4 changegroup for revlog v2 exchange...
r47445 b'sidedata': rlog.sidedata(r),
Augie Fackler
formatting: blacken the codebase...
r43346 }
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Durham Goode
revlog: add revmap back to revlog.addgroup...
r34292 def deltaiter(self):
Durham Goode
changegroup: remove changegroup dependency from revlog.addgroup...
r34147 chain = None
for chunkdata in iter(lambda: self.deltachunk(chain), {}):
Augie Fackler
tests: port test-revlog-raw.py to Python 3...
r37913 node = chunkdata[b'node']
p1 = chunkdata[b'p1']
p2 = chunkdata[b'p2']
cs = chunkdata[b'cs']
deltabase = chunkdata[b'deltabase']
delta = chunkdata[b'delta']
flags = chunkdata[b'flags']
Raphaël Gomès
changegroup: add v4 changegroup for revlog v2 exchange...
r47445 sidedata = chunkdata[b'sidedata']
Durham Goode
changegroup: remove changegroup dependency from revlog.addgroup...
r34147
chain = node
Raphaël Gomès
changegroup: add v4 changegroup for revlog v2 exchange...
r47445 yield (node, p1, p2, cs, deltabase, delta, flags, sidedata)
Durham Goode
changegroup: remove changegroup dependency from revlog.addgroup...
r34147
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def linkmap(lnode):
return rlog.rev(lnode)
dlog = newrevlog(destname, recreate=True)
Durham Goode
revlog: add revmap back to revlog.addgroup...
r34292 dummydeltas = dummychangegroup().deltaiter()
dlog.addgroup(dummydeltas, linkmap, tr)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 return dlog
Augie Fackler
formatting: blacken the codebase...
r43346
revlog: use a "radix" to address revlog...
r47921 def lowlevelcopy(rlog, tr, destname=b'_destrevlog'):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Like addgroupcopy, but use the low level revlog._addrevision directly.
Jun Wu
revlog: add a stronger test for raw processing...
r31748
It exercises some code paths that are hard to reach easily otherwise.
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Jun Wu
revlog: add a stronger test for raw processing...
r31748 dlog = newrevlog(destname, recreate=True)
for r in rlog:
p1 = rlog.node(r - 1)
Joerg Sonnenberger
node: replace nullid and friends with nodeconstants class...
r47771 p2 = rlog.nullid
Jun Wu
revlog: do not use delta for lfs revisions...
r36765 if r == 0 or (rlog.flags(r) & revlog.REVIDX_EXTSTORED):
rawdata: update callers in test-revlog-raw...
r43045 text = rlog.rawdata(r)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 cachedelta = None
else:
Jun Wu
revlog: do not use delta for lfs revisions...
r36765 # deltaparent cannot have EXTSTORED flag.
Augie Fackler
formatting: blacken the codebase...
r43346 deltaparent = max(
[-1]
+ [
p
for p in range(r)
if rlog.flags(p) & revlog.REVIDX_EXTSTORED == 0
]
)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 text = None
cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
flags = rlog.flags(r)
revlog: introduce a mandatory `_writing` context to update revlog content...
r47988 with dlog._writing(_NoTransaction()):
Augie Fackler
formatting: blacken the codebase...
r43346 dlog._addrevision(
revlog: introduce a mandatory `_writing` context to update revlog content...
r47988 rlog.node(r),
text,
tr,
r,
p1,
p2,
flags,
cachedelta,
Augie Fackler
formatting: blacken the codebase...
r43346 )
Jun Wu
revlog: add a stronger test for raw processing...
r31748 return dlog
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # Utilities to generate revisions for testing
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def genbits(n):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Given a number n, generate (2 ** (n * 2) + 1) numbers in range(2 ** n).
Jun Wu
revlog: add a stronger test for raw processing...
r31748 i.e. the generated numbers have a width of n bits.
The combination of two adjacent numbers will cover all possible cases.
That is to say, given any x, y where both x, and y are in range(2 ** n),
there is an x followed immediately by y in the generated sequence.
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Raphaël Gomès
black: format the codebase with 23.3.0...
r52596 m = 2**n
Jun Wu
revlog: add a stronger test for raw processing...
r31748
# Gray Code. See https://en.wikipedia.org/wiki/Gray_code
gray = lambda x: x ^ (x >> 1)
Augie Fackler
cleanup: run pyupgrade on our source tree to clean up varying things...
r44937 reversegray = {gray(i): i for i in range(m)}
Jun Wu
revlog: add a stronger test for raw processing...
r31748
# Generate (n * 2) bit gray code, yield lower n bits as X, and look for
# the next unused gray code where higher n bits equal to X.
# For gray codes whose higher bits are X, a[X] of them have been used.
a = [0] * m
# Iterate from 0.
x = 0
yield x
for i in range(m * m):
Jun Wu
test-revlog-raw: fix "genbits" implementation...
r31763 x = reversegray[x]
Jun Wu
revlog: add a stronger test for raw processing...
r31748 y = gray(a[x] + x * m) & (m - 1)
Jun Wu
test-revlog-raw: fix "genbits" implementation...
r31763 assert a[x] < m
Jun Wu
revlog: add a stronger test for raw processing...
r31748 a[x] += 1
x = y
yield x
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def gentext(rev):
'''Given a revision number, generate dummy text'''
return b''.join(b'%d\n' % j for j in range(-1, rev % 5))
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def writecases(rlog, tr):
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """Write some revisions interested to the test.
Jun Wu
revlog: add a stronger test for raw processing...
r31748
The test is interested in 3 properties of a revision:
- Is it a delta or a full text? (isdelta)
This is to catch some delta application issues.
- Does it have a flag of EXTSTORED? (isext)
This is to catch some flag processor issues. Especially when
interacted with revlog deltas.
- Is its text empty? (isempty)
This is less important. It is intended to try to catch some careless
checks like "if text" instead of "if text is None". Note: if flag
processor is involved, raw text may be not empty.
Write 65 revisions. So that all combinations of the above flags for
adjacent revisions are covered. That is to say,
len(set(
(r.delta, r.ext, r.empty, (r+1).delta, (r+1).ext, (r+1).empty)
for r in range(len(rlog) - 1)
)) is 64.
Where "r.delta", "r.ext", and "r.empty" are booleans matching properties
mentioned above.
Return expected [(text, rawtext)].
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 """
Jun Wu
revlog: add a stronger test for raw processing...
r31748 result = []
for i, x in enumerate(genbits(3)):
isdelta, isext, isempty = bool(x & 1), bool(x & 2), bool(x & 4)
if isempty:
text = b''
else:
text = gentext(i)
rev = appendrev(rlog, text, tr, isext=isext, isdelta=isdelta)
# Verify text, rawtext, and rawsize
if isext:
Raphaël Gomès
sidedata: move to new sidedata storage in revlogv2...
r47443 rawtext = writeprocessor(None, text)[0]
Jun Wu
revlog: add a stronger test for raw processing...
r31748 else:
rawtext = text
if rlog.rawsize(rev) != len(rawtext):
abort('rev %d: wrong rawsize' % rev)
Raphaël Gomès
revlog: remove deprecated APIs...
r49360 if rlog.revision(rev) != text:
Jun Wu
revlog: add a stronger test for raw processing...
r31748 abort('rev %d: wrong text' % rev)
rawdata: update callers in test-revlog-raw...
r43045 if rlog.rawdata(rev) != rawtext:
Jun Wu
revlog: add a stronger test for raw processing...
r31748 abort('rev %d: wrong rawtext' % rev)
result.append((text, rawtext))
# Verify flags like isdelta, isext work as expected
Jun Wu
revlog: do not use delta for lfs revisions...
r36765 # isdelta can be overridden to False if this or p1 has isext set
if bool(rlog.deltaparent(rev) > -1) and not isdelta:
abort('rev %d: isdelta is unexpected' % rev)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 if bool(rlog.flags(rev)) != isext:
abort('rev %d: isext is ineffective' % rev)
return result
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 # Main test and checking
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def checkrevlog(rlog, expected):
'''Check if revlog has expected contents. expected is [(text, rawtext)]'''
# Test using different access orders. This could expose some issues
# depending on revlog caching (see revlog._cache).
for r0 in range(len(rlog) - 1):
r1 = r0 + 1
for revorder in [[r0, r1], [r1, r0]]:
for raworder in [[True], [False], [True, False], [False, True]]:
nlog = newrevlog()
for rev in revorder:
for raw in raworder:
rawdata: update callers in test-revlog-raw...
r43045 if raw:
t = nlog.rawdata(rev)
else:
t = nlog.revision(rev)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 if t != expected[rev][int(raw)]:
Augie Fackler
formatting: blacken the codebase...
r43346 abort(
'rev %d: corrupted %stext'
% (rev, raw and 'raw' or '')
)
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 slicingdata = [
Augie Fackler
formatting: blacken the codebase...
r43346 ([0, 1, 2, 3, 55, 56, 58, 59, 60], [[0, 1], [2], [58], [59, 60]], 10),
([0, 1, 2, 3, 55, 56, 58, 59, 60], [[0, 1], [2], [58], [59, 60]], 10),
(
[-1, 0, 1, 2, 3, 55, 56, 58, 59, 60],
[[-1, 0, 1], [2], [58], [59, 60]],
10,
),
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 ]
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 def slicingtest(rlog):
revlog: overwrite revlog config through copy of the config object...
r51923 old_delta_config = rlog.delta_config
old_data_config = rlog.data_config
rlog.delta_config = rlog.delta_config.copy()
rlog.data_config = rlog.data_config.copy()
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 try:
# the test revlog is small, we remove the floor under which we
# slicing is diregarded.
revlog: move configuration attribute into dedicated object...
r51922 rlog.data_config.sr_min_gap_size = 0
rlog.delta_config.sr_min_gap_size = 0
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 for item in slicingdata:
chain, expected, target = item
result = deltas.slicechunk(rlog, chain, targetsize=target)
result = list(result)
if result != expected:
print('slicing differ:')
print(' chain: %s' % chain)
print(' target: %s' % target)
print(' expected: %s' % expected)
print(' result: %s' % result)
finally:
revlog: overwrite revlog config through copy of the config object...
r51923 rlog.delta_config = old_delta_config
rlog.data_config = old_data_config
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 def md5sum(s):
return hashlib.md5(s).digest()
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 def _maketext(*coord):
"""create piece of text according to range of integers
The test returned use a md5sum of the integer to make it less
compressible"""
pieces = []
for start, size in coord:
num = range(start, start + size)
p = [md5sum(b'%d' % r) for r in num]
pieces.append(b'\n'.join(p))
return b'\n'.join(pieces) + b'\n'
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 data = [
_maketext((0, 120), (456, 60)),
_maketext((0, 120), (345, 60)),
_maketext((0, 120), (734, 60)),
_maketext((0, 120), (734, 60), (923, 45)),
_maketext((0, 120), (734, 60), (234, 45)),
_maketext((0, 120), (734, 60), (564, 45)),
_maketext((0, 120), (734, 60), (361, 45)),
_maketext((0, 120), (734, 60), (489, 45)),
_maketext((0, 120), (123, 60)),
_maketext((0, 120), (145, 60)),
_maketext((0, 120), (104, 60)),
_maketext((0, 120), (430, 60)),
_maketext((0, 120), (430, 60), (923, 45)),
_maketext((0, 120), (430, 60), (234, 45)),
_maketext((0, 120), (430, 60), (564, 45)),
_maketext((0, 120), (430, 60), (361, 45)),
_maketext((0, 120), (430, 60), (489, 45)),
_maketext((0, 120), (249, 60)),
_maketext((0, 120), (832, 60)),
_maketext((0, 120), (891, 60)),
_maketext((0, 120), (543, 60)),
_maketext((0, 120), (120, 60)),
_maketext((0, 120), (60, 60), (768, 30)),
_maketext((0, 120), (60, 60), (260, 30)),
_maketext((0, 120), (60, 60), (450, 30)),
_maketext((0, 120), (60, 60), (361, 30)),
_maketext((0, 120), (60, 60), (886, 30)),
_maketext((0, 120), (60, 60), (116, 30)),
_maketext((0, 120), (60, 60), (567, 30), (629, 40)),
_maketext((0, 120), (60, 60), (569, 30), (745, 40)),
_maketext((0, 120), (60, 60), (777, 30), (700, 40)),
_maketext((0, 120), (60, 60), (618, 30), (398, 40), (158, 10)),
]
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 def makesnapshot(tr):
revlog: use a "radix" to address revlog...
r47921 rl = newrevlog(name=b'_snaprevlog3', recreate=True)
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 for i in data:
appendrev(rl, i, tr)
return rl
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 snapshots = [-1, 0, 6, 8, 11, 17, 19, 21, 25, 30]
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 def issnapshottest(rlog):
result = []
if rlog.issnapshot(-1):
result.append(-1)
for rev in rlog:
if rlog.issnapshot(rev):
result.append(rev)
if snapshots != result:
print('snapshot differ:')
print(' expected: %s' % snapshots)
print(' got: %s' % result)
Augie Fackler
formatting: blacken the codebase...
r43346
delta-find: use sets instead of list in the snapshot cache...
r50574 snapshotmapall = {0: {6, 8, 11, 17, 19, 25}, 8: {21}, -1: {0, 30}}
snapshotmap15 = {0: {17, 19, 25}, 8: {21}, -1: {30}}
Augie Fackler
formatting: blacken the codebase...
r43346
Boris Feld
revlog: add test case for _findsnapshots...
r41119 def findsnapshottest(rlog):
delta-find: use a smarter object for snapshot caching...
r50573 cache = deltas.SnapshotCache()
cache.update(rlog)
resultall = dict(cache.snapshots)
Boris Feld
revlog: add test case for _findsnapshots...
r41119 if resultall != snapshotmapall:
print('snapshot map differ:')
print(' expected: %s' % snapshotmapall)
print(' got: %s' % resultall)
delta-find: use a smarter object for snapshot caching...
r50573 cache15 = deltas.SnapshotCache()
cache15.update(rlog, 15)
result15 = dict(cache15.snapshots)
Boris Feld
revlog: add test case for _findsnapshots...
r41119 if result15 != snapshotmap15:
print('snapshot map differ:')
print(' expected: %s' % snapshotmap15)
print(' got: %s' % result15)
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 def maintest():
with newtransaction() as tr:
rl = newrevlog(recreate=True)
expected = writecases(rl, tr)
checkrevlog(rl, expected)
print('local test passed')
# Copy via revlog.addgroup
rl1 = addgroupcopy(rl, tr)
checkrevlog(rl1, expected)
rl2 = addgroupcopy(rl, tr, optimaldelta=False)
checkrevlog(rl2, expected)
print('addgroupcopy test passed')
# Copy via revlog.clone
revlog: use a "radix" to address revlog...
r47921 rl3 = newrevlog(name=b'_destrevlog3', recreate=True)
Jun Wu
revlog: add a stronger test for raw processing...
r31748 rl.clone(tr, rl3)
checkrevlog(rl3, expected)
print('clone test passed')
# Copy via low-level revlog._addrevision
rl4 = lowlevelcopy(rl, tr)
checkrevlog(rl4, expected)
print('lowlevelcopy test passed')
Boris Feld
revlog: add some direct testing of the slicing logic...
r41063 slicingtest(rl)
print('slicing test passed')
Boris Feld
revlog: add an explicit test for `issnapshot`...
r41064 rl5 = makesnapshot(tr)
issnapshottest(rl5)
print('issnapshot test passed')
Boris Feld
revlog: add test case for _findsnapshots...
r41119 findsnapshottest(rl5)
print('findsnapshot test passed')
Jun Wu
revlog: add a stronger test for raw processing...
r31748
Augie Fackler
formatting: blacken the codebase...
r43346
Jun Wu
revlog: add a stronger test for raw processing...
r31748 try:
maintest()
except Exception as ex:
abort('crashed: %s' % ex)