- skip-blame just b prefixes
Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG03a09579c854: tests: port test-revlog-raw.py to Python 3
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | tests/test-revlog-raw.py (32 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Augie Fackler | Apr 27 2018, 10:46 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
# test revlog interaction about raw data (flagprocessor) | # test revlog interaction about raw data (flagprocessor) | ||||
from __future__ import absolute_import, print_function | from __future__ import absolute_import, print_function | ||||
import sys | import sys | ||||
from mercurial import ( | from mercurial import ( | ||||
encoding, | encoding, | ||||
node, | node, | ||||
revlog, | revlog, | ||||
transaction, | transaction, | ||||
vfs, | vfs, | ||||
) | ) | ||||
# TESTTMP is optional. This makes it convenient to run without run-tests.py | # TESTTMP is optional. This makes it convenient to run without run-tests.py | ||||
tvfs = vfs.vfs(encoding.environ.get('TESTTMP', b'/tmp')) | tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp')) | ||||
# Enable generaldelta otherwise revlog won't use delta as expected by the test | # Enable generaldelta otherwise revlog won't use delta as expected by the test | ||||
tvfs.options = {'generaldelta': True, 'revlogv1': True} | tvfs.options = {b'generaldelta': True, b'revlogv1': True} | ||||
# The test wants to control whether to use delta explicitly, based on | # The test wants to control whether to use delta explicitly, based on | ||||
# "storedeltachains". | # "storedeltachains". | ||||
revlog.revlog._isgooddeltainfo = lambda self, d, textlen: self.storedeltachains | revlog.revlog._isgooddeltainfo = lambda self, d, textlen: self.storedeltachains | ||||
def abort(msg): | def abort(msg): | ||||
print('abort: %s' % msg) | print('abort: %s' % msg) | ||||
# Return 0 so run-tests.py could compare the output. | # Return 0 so run-tests.py could compare the output. | ||||
return {} | return {} | ||||
if optimaldelta: | if optimaldelta: | ||||
deltaparent = parentrev | deltaparent = parentrev | ||||
else: | else: | ||||
# suboptimal deltaparent | # suboptimal deltaparent | ||||
deltaparent = min(0, parentrev) | deltaparent = min(0, parentrev) | ||||
if not rlog.candelta(deltaparent, r): | if not rlog.candelta(deltaparent, r): | ||||
deltaparent = -1 | deltaparent = -1 | ||||
return {'node': rlog.node(r), 'p1': pnode, 'p2': node.nullid, | return {b'node': rlog.node(r), b'p1': pnode, b'p2': node.nullid, | ||||
'cs': rlog.node(rlog.linkrev(r)), 'flags': rlog.flags(r), | b'cs': rlog.node(rlog.linkrev(r)), b'flags': rlog.flags(r), | ||||
'deltabase': rlog.node(deltaparent), | b'deltabase': rlog.node(deltaparent), | ||||
'delta': rlog.revdiff(deltaparent, r)} | b'delta': rlog.revdiff(deltaparent, r)} | ||||
def deltaiter(self): | def deltaiter(self): | ||||
chain = None | chain = None | ||||
for chunkdata in iter(lambda: self.deltachunk(chain), {}): | for chunkdata in iter(lambda: self.deltachunk(chain), {}): | ||||
node = chunkdata['node'] | node = chunkdata[b'node'] | ||||
p1 = chunkdata['p1'] | p1 = chunkdata[b'p1'] | ||||
p2 = chunkdata['p2'] | p2 = chunkdata[b'p2'] | ||||
cs = chunkdata['cs'] | cs = chunkdata[b'cs'] | ||||
deltabase = chunkdata['deltabase'] | deltabase = chunkdata[b'deltabase'] | ||||
delta = chunkdata['delta'] | delta = chunkdata[b'delta'] | ||||
flags = chunkdata['flags'] | flags = chunkdata[b'flags'] | ||||
chain = node | chain = node | ||||
yield (node, p1, p2, cs, deltabase, delta, flags) | yield (node, p1, p2, cs, deltabase, delta, flags) | ||||
def linkmap(lnode): | def linkmap(lnode): | ||||
return rlog.rev(lnode) | return rlog.rev(lnode) | ||||
deltaparent = max([-1] + | deltaparent = max([-1] + | ||||
[p for p in range(r) | [p for p in range(r) | ||||
if rlog.flags(p) & revlog.REVIDX_EXTSTORED == 0]) | if rlog.flags(p) & revlog.REVIDX_EXTSTORED == 0]) | ||||
text = None | text = None | ||||
cachedelta = (deltaparent, rlog.revdiff(deltaparent, r)) | cachedelta = (deltaparent, rlog.revdiff(deltaparent, r)) | ||||
flags = rlog.flags(r) | flags = rlog.flags(r) | ||||
ifh = dfh = None | ifh = dfh = None | ||||
try: | try: | ||||
ifh = dlog.opener(dlog.indexfile, 'a+') | ifh = dlog.opener(dlog.indexfile, b'a+') | ||||
if not dlog._inline: | if not dlog._inline: | ||||
dfh = dlog.opener(dlog.datafile, 'a+') | dfh = dlog.opener(dlog.datafile, b'a+') | ||||
dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, | dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, | ||||
cachedelta, ifh, dfh) | cachedelta, ifh, dfh) | ||||
finally: | finally: | ||||
if dfh is not None: | if dfh is not None: | ||||
dfh.close() | dfh.close() | ||||
if ifh is not None: | if ifh is not None: | ||||
ifh.close() | ifh.close() | ||||
return dlog | return dlog | ||||
print('local test passed') | print('local test passed') | ||||
# Copy via revlog.addgroup | # Copy via revlog.addgroup | ||||
rl1 = addgroupcopy(rl, tr) | rl1 = addgroupcopy(rl, tr) | ||||
checkrevlog(rl1, expected) | checkrevlog(rl1, expected) | ||||
rl2 = addgroupcopy(rl, tr, optimaldelta=False) | rl2 = addgroupcopy(rl, tr, optimaldelta=False) | ||||
checkrevlog(rl2, expected) | checkrevlog(rl2, expected) | ||||
print('addgroupcopy test passed') | print('addgroupcopy test passed') | ||||
# Copy via revlog.clone | # Copy via revlog.clone | ||||
rl3 = newrevlog(name='_destrevlog3.i', recreate=True) | rl3 = newrevlog(name=b'_destrevlog3.i', recreate=True) | ||||
rl.clone(tr, rl3) | rl.clone(tr, rl3) | ||||
checkrevlog(rl3, expected) | checkrevlog(rl3, expected) | ||||
print('clone test passed') | print('clone test passed') | ||||
# Copy via low-level revlog._addrevision | # Copy via low-level revlog._addrevision | ||||
rl4 = lowlevelcopy(rl, tr) | rl4 = lowlevelcopy(rl, tr) | ||||
checkrevlog(rl4, expected) | checkrevlog(rl4, expected) | ||||
print('lowlevelcopy test passed') | print('lowlevelcopy test passed') | ||||
try: | try: | ||||
maintest() | maintest() | ||||
except Exception as ex: | except Exception as ex: | ||||
abort('crashed: %s' % ex) | abort('crashed: %s' % ex) |