annotate tests/test-revlog-raw.py @ 41844:2105ed01c431

tests: make test-status.t compatible with test-check-module-imports.t Otherwise the later fails on Python 3. Differential Revision: https://phab.mercurial-scm.org/D6072
author Pulkit Goyal <pulkit@yandex-team.ru>
date Tue, 05 Mar 2019 04:32:23 +0530
parents 876494fd967d
children 6d61be152c55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
1 # test revlog interaction about raw data (flagprocessor)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
2
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
3 from __future__ import absolute_import, print_function
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
4
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
5 import collections
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
6 import hashlib
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
7 import sys
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
8
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
9 from mercurial import (
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
10 encoding,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
11 node,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
12 revlog,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
13 transaction,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
14 vfs,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
15 )
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
16
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
17 from mercurial.revlogutils import (
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
18 deltas,
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
19 )
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
20
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
21 # TESTTMP is optional. This makes it convenient to run without run-tests.py
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
22 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp'))
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
23
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
24 # Enable generaldelta otherwise revlog won't use delta as expected by the test
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
25 tvfs.options = {b'generaldelta': True, b'revlogv1': True,
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
26 b'sparse-revlog': True}
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
27
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
28 # The test wants to control whether to use delta explicitly, based on
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
29 # "storedeltachains".
39232
0a5b20c107a6 repository: remove storedeltachains from ifilestorage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37896
diff changeset
30 revlog.revlog._isgooddeltainfo = lambda self, d, textlen: self._storedeltachains
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
31
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
32 def abort(msg):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
33 print('abort: %s' % msg)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
34 # Return 0 so run-tests.py could compare the output.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
35 sys.exit()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
36
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
37 # Register a revlog processor for flag EXTSTORED.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
38 #
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
39 # It simply prepends a fixed header, and replaces '1' to 'i'. So it has
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
40 # insertion and replacement, and may be interesting to test revlog's line-based
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
41 # deltas.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
42 _extheader = b'E\n'
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
43
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
44 def readprocessor(self, rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
45 # True: the returned text could be used to verify hash
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
46 text = rawtext[len(_extheader):].replace(b'i', b'1')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
47 return text, True
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
48
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
49 def writeprocessor(self, text):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
50 # False: the returned rawtext shouldn't be used to verify hash
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
51 rawtext = _extheader + text.replace(b'1', b'i')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
52 return rawtext, False
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
53
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
54 def rawprocessor(self, rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
55 # False: do not verify hash. Only the content returned by "readprocessor"
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
56 # can be used to verify hash.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
57 return False
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
58
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
59 revlog.addflagprocessor(revlog.REVIDX_EXTSTORED,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
60 (readprocessor, writeprocessor, rawprocessor))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
61
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
62 # Utilities about reading and appending revlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
63
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
64 def newtransaction():
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
65 # A transaction is required to write revlogs
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
66 report = lambda msg: None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
67 return transaction.transaction(report, tvfs, {'plain': tvfs}, b'journal')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
68
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
69 def newrevlog(name=b'_testrevlog.i', recreate=False):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
70 if recreate:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
71 tvfs.tryunlink(name)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
72 rlog = revlog.revlog(tvfs, name)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
73 return rlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
74
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
75 def appendrev(rlog, text, tr, isext=False, isdelta=True):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
76 '''Append a revision. If isext is True, set the EXTSTORED flag so flag
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
77 processor will be used (and rawtext is different from text). If isdelta is
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
78 True, force the revision to be a delta, otherwise it's full text.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
79 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
80 nextrev = len(rlog)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
81 p1 = rlog.node(nextrev - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
82 p2 = node.nullid
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
83 if isext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
84 flags = revlog.REVIDX_EXTSTORED
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
85 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
86 flags = revlog.REVIDX_DEFAULT_FLAGS
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
87 # Change storedeltachains temporarily, to override revlog's delta decision
39232
0a5b20c107a6 repository: remove storedeltachains from ifilestorage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37896
diff changeset
88 rlog._storedeltachains = isdelta
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
89 try:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
90 rlog.addrevision(text, tr, nextrev, p1, p2, flags=flags)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
91 return nextrev
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
92 except Exception as ex:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
93 abort('rev %d: failed to append: %s' % (nextrev, ex))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
94 finally:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
95 # Restore storedeltachains. It is always True, see revlog.__init__
39232
0a5b20c107a6 repository: remove storedeltachains from ifilestorage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37896
diff changeset
96 rlog._storedeltachains = True
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
97
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
98 def addgroupcopy(rlog, tr, destname=b'_destrevlog.i', optimaldelta=True):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
99 '''Copy revlog to destname using revlog.addgroup. Return the copied revlog.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
100
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
101 This emulates push or pull. They use changegroup. Changegroup requires
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
102 repo to work. We don't have a repo, so a dummy changegroup is used.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
103
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
104 If optimaldelta is True, use optimized delta parent, so the destination
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
105 revlog could probably reuse it. Otherwise it builds sub-optimal delta, and
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
106 the destination revlog needs more work to use it.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
107
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
108 This exercises some revlog.addgroup (and revlog._addrevision(text=None))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
109 code path, which is not covered by "appendrev" alone.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
110 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
111 class dummychangegroup(object):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
112 @staticmethod
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
113 def deltachunk(pnode):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
114 pnode = pnode or node.nullid
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
115 parentrev = rlog.rev(pnode)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
116 r = parentrev + 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
117 if r >= len(rlog):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
118 return {}
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
119 if optimaldelta:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
120 deltaparent = parentrev
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
121 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
122 # suboptimal deltaparent
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
123 deltaparent = min(0, parentrev)
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
124 if not rlog.candelta(deltaparent, r):
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
125 deltaparent = -1
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
126 return {b'node': rlog.node(r), b'p1': pnode, b'p2': node.nullid,
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
127 b'cs': rlog.node(rlog.linkrev(r)), b'flags': rlog.flags(r),
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
128 b'deltabase': rlog.node(deltaparent),
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
129 b'delta': rlog.revdiff(deltaparent, r)}
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
130
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
131 def deltaiter(self):
34148
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
132 chain = None
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
133 for chunkdata in iter(lambda: self.deltachunk(chain), {}):
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
134 node = chunkdata[b'node']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
135 p1 = chunkdata[b'p1']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
136 p2 = chunkdata[b'p2']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
137 cs = chunkdata[b'cs']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
138 deltabase = chunkdata[b'deltabase']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
139 delta = chunkdata[b'delta']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
140 flags = chunkdata[b'flags']
34148
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
141
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
142 chain = node
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
143
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
144 yield (node, p1, p2, cs, deltabase, delta, flags)
34148
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
145
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
146 def linkmap(lnode):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
147 return rlog.rev(lnode)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
148
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
149 dlog = newrevlog(destname, recreate=True)
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
150 dummydeltas = dummychangegroup().deltaiter()
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
151 dlog.addgroup(dummydeltas, linkmap, tr)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
152 return dlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
153
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
154 def lowlevelcopy(rlog, tr, destname=b'_destrevlog.i'):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
155 '''Like addgroupcopy, but use the low level revlog._addrevision directly.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
156
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
157 It exercises some code paths that are hard to reach easily otherwise.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
158 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
159 dlog = newrevlog(destname, recreate=True)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
160 for r in rlog:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
161 p1 = rlog.node(r - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
162 p2 = node.nullid
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
163 if r == 0 or (rlog.flags(r) & revlog.REVIDX_EXTSTORED):
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
164 text = rlog.revision(r, raw=True)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
165 cachedelta = None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
166 else:
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
167 # deltaparent cannot have EXTSTORED flag.
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
168 deltaparent = max([-1] +
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
169 [p for p in range(r)
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
170 if rlog.flags(p) & revlog.REVIDX_EXTSTORED == 0])
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
171 text = None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
172 cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
173 flags = rlog.flags(r)
33625
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
174 ifh = dfh = None
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
175 try:
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
176 ifh = dlog.opener(dlog.indexfile, b'a+')
33625
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
177 if not dlog._inline:
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
178 dfh = dlog.opener(dlog.datafile, b'a+')
33625
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
179 dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags,
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
180 cachedelta, ifh, dfh)
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
181 finally:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
182 if dfh is not None:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
183 dfh.close()
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
184 if ifh is not None:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
185 ifh.close()
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
186 return dlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
187
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
188 # Utilities to generate revisions for testing
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
189
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
190 def genbits(n):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
191 '''Given a number n, generate (2 ** (n * 2) + 1) numbers in range(2 ** n).
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
192 i.e. the generated numbers have a width of n bits.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
193
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
194 The combination of two adjacent numbers will cover all possible cases.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
195 That is to say, given any x, y where both x, and y are in range(2 ** n),
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
196 there is an x followed immediately by y in the generated sequence.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
197 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
198 m = 2 ** n
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
199
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
200 # Gray Code. See https://en.wikipedia.org/wiki/Gray_code
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
201 gray = lambda x: x ^ (x >> 1)
31763
8a0c47982ade test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents: 31748
diff changeset
202 reversegray = dict((gray(i), i) for i in range(m))
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
203
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
204 # Generate (n * 2) bit gray code, yield lower n bits as X, and look for
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
205 # the next unused gray code where higher n bits equal to X.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
206
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
207 # For gray codes whose higher bits are X, a[X] of them have been used.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
208 a = [0] * m
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
209
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
210 # Iterate from 0.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
211 x = 0
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
212 yield x
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
213 for i in range(m * m):
31763
8a0c47982ade test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents: 31748
diff changeset
214 x = reversegray[x]
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
215 y = gray(a[x] + x * m) & (m - 1)
31763
8a0c47982ade test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents: 31748
diff changeset
216 assert a[x] < m
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
217 a[x] += 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
218 x = y
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
219 yield x
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
220
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
221 def gentext(rev):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
222 '''Given a revision number, generate dummy text'''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
223 return b''.join(b'%d\n' % j for j in range(-1, rev % 5))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
224
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
225 def writecases(rlog, tr):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
226 '''Write some revisions interested to the test.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
227
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
228 The test is interested in 3 properties of a revision:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
229
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
230 - Is it a delta or a full text? (isdelta)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
231 This is to catch some delta application issues.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
232 - Does it have a flag of EXTSTORED? (isext)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
233 This is to catch some flag processor issues. Especially when
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
234 interacted with revlog deltas.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
235 - Is its text empty? (isempty)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
236 This is less important. It is intended to try to catch some careless
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
237 checks like "if text" instead of "if text is None". Note: if flag
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
238 processor is involved, raw text may be not empty.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
239
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
240 Write 65 revisions. So that all combinations of the above flags for
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
241 adjacent revisions are covered. That is to say,
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
242
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
243 len(set(
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
244 (r.delta, r.ext, r.empty, (r+1).delta, (r+1).ext, (r+1).empty)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
245 for r in range(len(rlog) - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
246 )) is 64.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
247
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
248 Where "r.delta", "r.ext", and "r.empty" are booleans matching properties
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
249 mentioned above.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
250
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
251 Return expected [(text, rawtext)].
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
252 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
253 result = []
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
254 for i, x in enumerate(genbits(3)):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
255 isdelta, isext, isempty = bool(x & 1), bool(x & 2), bool(x & 4)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
256 if isempty:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
257 text = b''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
258 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
259 text = gentext(i)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
260 rev = appendrev(rlog, text, tr, isext=isext, isdelta=isdelta)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
261
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
262 # Verify text, rawtext, and rawsize
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
263 if isext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
264 rawtext = writeprocessor(None, text)[0]
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
265 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
266 rawtext = text
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
267 if rlog.rawsize(rev) != len(rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
268 abort('rev %d: wrong rawsize' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
269 if rlog.revision(rev, raw=False) != text:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
270 abort('rev %d: wrong text' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
271 if rlog.revision(rev, raw=True) != rawtext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
272 abort('rev %d: wrong rawtext' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
273 result.append((text, rawtext))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
274
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
275 # Verify flags like isdelta, isext work as expected
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
276 # isdelta can be overridden to False if this or p1 has isext set
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
277 if bool(rlog.deltaparent(rev) > -1) and not isdelta:
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
278 abort('rev %d: isdelta is unexpected' % rev)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
279 if bool(rlog.flags(rev)) != isext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
280 abort('rev %d: isext is ineffective' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
281 return result
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
282
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
283 # Main test and checking
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
284
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
285 def checkrevlog(rlog, expected):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
286 '''Check if revlog has expected contents. expected is [(text, rawtext)]'''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
287 # Test using different access orders. This could expose some issues
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
288 # depending on revlog caching (see revlog._cache).
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
289 for r0 in range(len(rlog) - 1):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
290 r1 = r0 + 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
291 for revorder in [[r0, r1], [r1, r0]]:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
292 for raworder in [[True], [False], [True, False], [False, True]]:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
293 nlog = newrevlog()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
294 for rev in revorder:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
295 for raw in raworder:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
296 t = nlog.revision(rev, raw=raw)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
297 if t != expected[rev][int(raw)]:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
298 abort('rev %d: corrupted %stext'
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
299 % (rev, raw and 'raw' or ''))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
300
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
301 slicingdata = [
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
302 ([0, 1, 2, 3, 55, 56, 58, 59, 60],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
303 [[0, 1], [2], [58], [59, 60]],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
304 10),
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
305 ([0, 1, 2, 3, 55, 56, 58, 59, 60],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
306 [[0, 1], [2], [58], [59, 60]],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
307 10),
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
308 ([-1, 0, 1, 2, 3, 55, 56, 58, 59, 60],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
309 [[-1, 0, 1], [2], [58], [59, 60]],
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
310 10),
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
311 ]
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
312
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
313 def slicingtest(rlog):
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
314 oldmin = rlog._srmingapsize
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
315 try:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
316 # the test revlog is small, we remove the floor under which we
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
317 # slicing is diregarded.
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
318 rlog._srmingapsize = 0
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
319 for item in slicingdata:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
320 chain, expected, target = item
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
321 result = deltas.slicechunk(rlog, chain, targetsize=target)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
322 result = list(result)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
323 if result != expected:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
324 print('slicing differ:')
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
325 print(' chain: %s' % chain)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
326 print(' target: %s' % target)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
327 print(' expected: %s' % expected)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
328 print(' result: %s' % result)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
329 finally:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
330 rlog._srmingapsize = oldmin
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
331
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
332 def md5sum(s):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
333 return hashlib.md5(s).digest()
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
334
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
335 def _maketext(*coord):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
336 """create piece of text according to range of integers
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
337
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
338 The test returned use a md5sum of the integer to make it less
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
339 compressible"""
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
340 pieces = []
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
341 for start, size in coord:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
342 num = range(start, start + size)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
343 p = [md5sum(b'%d' % r) for r in num]
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
344 pieces.append(b'\n'.join(p))
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
345 return b'\n'.join(pieces) + b'\n'
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
346
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
347 data = [
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
348 _maketext((0, 120), (456, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
349 _maketext((0, 120), (345, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
350 _maketext((0, 120), (734, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
351 _maketext((0, 120), (734, 60), (923, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
352 _maketext((0, 120), (734, 60), (234, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
353 _maketext((0, 120), (734, 60), (564, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
354 _maketext((0, 120), (734, 60), (361, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
355 _maketext((0, 120), (734, 60), (489, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
356 _maketext((0, 120), (123, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
357 _maketext((0, 120), (145, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
358 _maketext((0, 120), (104, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
359 _maketext((0, 120), (430, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
360 _maketext((0, 120), (430, 60), (923, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
361 _maketext((0, 120), (430, 60), (234, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
362 _maketext((0, 120), (430, 60), (564, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
363 _maketext((0, 120), (430, 60), (361, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
364 _maketext((0, 120), (430, 60), (489, 45)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
365 _maketext((0, 120), (249, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
366 _maketext((0, 120), (832, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
367 _maketext((0, 120), (891, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
368 _maketext((0, 120), (543, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
369 _maketext((0, 120), (120, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
370 _maketext((0, 120), (60, 60), (768, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
371 _maketext((0, 120), (60, 60), (260, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
372 _maketext((0, 120), (60, 60), (450, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
373 _maketext((0, 120), (60, 60), (361, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
374 _maketext((0, 120), (60, 60), (886, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
375 _maketext((0, 120), (60, 60), (116, 30)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
376 _maketext((0, 120), (60, 60), (567, 30), (629, 40)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
377 _maketext((0, 120), (60, 60), (569, 30), (745, 40)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
378 _maketext((0, 120), (60, 60), (777, 30), (700, 40)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
379 _maketext((0, 120), (60, 60), (618, 30), (398, 40), (158, 10)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
380 ]
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
381
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
382 def makesnapshot(tr):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
383 rl = newrevlog(name=b'_snaprevlog3.i', recreate=True)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
384 for i in data:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
385 appendrev(rl, i, tr)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
386 return rl
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
387
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
388 snapshots = [-1, 0, 6, 8, 11, 17, 19, 21, 25, 30]
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
389 def issnapshottest(rlog):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
390 result = []
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
391 if rlog.issnapshot(-1):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
392 result.append(-1)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
393 for rev in rlog:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
394 if rlog.issnapshot(rev):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
395 result.append(rev)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
396 if snapshots != result:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
397 print('snapshot differ:')
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
398 print(' expected: %s' % snapshots)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
399 print(' got: %s' % result)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
400
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
401 snapshotmapall = {0: [6, 8, 11, 17, 19, 25], 8: [21], -1: [0, 30]}
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
402 snapshotmap15 = {0: [17, 19, 25], 8: [21], -1: [30]}
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
403 def findsnapshottest(rlog):
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
404 resultall = collections.defaultdict(list)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
405 deltas._findsnapshots(rlog, resultall, 0)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
406 resultall = dict(resultall.items())
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
407 if resultall != snapshotmapall:
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
408 print('snapshot map differ:')
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
409 print(' expected: %s' % snapshotmapall)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
410 print(' got: %s' % resultall)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
411 result15 = collections.defaultdict(list)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
412 deltas._findsnapshots(rlog, result15, 15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
413 result15 = dict(result15.items())
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
414 if result15 != snapshotmap15:
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
415 print('snapshot map differ:')
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
416 print(' expected: %s' % snapshotmap15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
417 print(' got: %s' % result15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
418
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
419 def maintest():
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
420 with newtransaction() as tr:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
421 rl = newrevlog(recreate=True)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
422 expected = writecases(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
423 checkrevlog(rl, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
424 print('local test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
425 # Copy via revlog.addgroup
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
426 rl1 = addgroupcopy(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
427 checkrevlog(rl1, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
428 rl2 = addgroupcopy(rl, tr, optimaldelta=False)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
429 checkrevlog(rl2, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
430 print('addgroupcopy test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
431 # Copy via revlog.clone
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
432 rl3 = newrevlog(name=b'_destrevlog3.i', recreate=True)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
433 rl.clone(tr, rl3)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
434 checkrevlog(rl3, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
435 print('clone test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
436 # Copy via low-level revlog._addrevision
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
437 rl4 = lowlevelcopy(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
438 checkrevlog(rl4, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
439 print('lowlevelcopy test passed')
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
440 slicingtest(rl)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
441 print('slicing test passed')
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
442 rl5 = makesnapshot(tr)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
443 issnapshottest(rl5)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
444 print('issnapshot test passed')
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
445 findsnapshottest(rl5)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
446 print('findsnapshot test passed')
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
447
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
448 try:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
449 maintest()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
450 except Exception as ex:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
451 abort('crashed: %s' % ex)