annotate tests/test-revlog-raw.py @ 44011:c627f1b2f3c3

rust-index: handle `MixedIndex` in `pyindex_to_graph` On the long run we will want to implement the Graph trait directly in Rust, but for now we take the path with the least amount of change to focus on the coming persistent NodeMap code. We test this new code through with the lazy ancestors code. Differential Revision: https://phab.mercurial-scm.org/D7657
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 12 Dec 2019 18:11:44 +0100
parents 2372284d9457
children 9d2b2df2c2ba
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,
42732
6d61be152c55 flagutil: move addflagprocessor to the new module (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41365
diff changeset
19 flagutil,
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
20 )
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
21
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
22 # 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
23 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
24
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
25 # Enable generaldelta otherwise revlog won't use delta as expected by the test
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
26 tvfs.options = {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
27 b'generaldelta': True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
28 b'revlogv1': True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
29 b'sparse-revlog': True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
30 }
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 # 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
33 # "storedeltachains".
39232
0a5b20c107a6 repository: remove storedeltachains from ifilestorage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37896
diff changeset
34 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
35
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
36
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
37 def abort(msg):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
38 print('abort: %s' % msg)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
39 # 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
40 sys.exit()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
41
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
42
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
43 # Register a revlog processor for flag EXTSTORED.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
44 #
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
45 # 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
46 # 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
47 # deltas.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
48 _extheader = b'E\n'
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
49
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
50
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
51 def readprocessor(self, rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
52 # True: the returned text could be used to verify hash
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
53 text = rawtext[len(_extheader) :].replace(b'i', b'1')
42985
bd5858c28bbe flagprocessors: have the read transform function return side data (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42777
diff changeset
54 return text, True, {}
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
55
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
56
42988
f4caf910669e flagprocessors: writetransform function take side data as parameter (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42985
diff changeset
57 def writeprocessor(self, text, sidedata):
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
58 # 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
59 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
60 return rawtext, False
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
61
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
62
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
63 def rawprocessor(self, rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
64 # 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
65 # can be used to verify hash.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
66 return False
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
67
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
68
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
69 flagutil.addflagprocessor(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
70 revlog.REVIDX_EXTSTORED, (readprocessor, writeprocessor, rawprocessor)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
71 )
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
72
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
73 # Utilities about reading and appending revlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
74
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
75
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
76 def newtransaction():
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
77 # A transaction is required to write revlogs
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
78 report = lambda msg: None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
79 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
80
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
81
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
82 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
83 if recreate:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
84 tvfs.tryunlink(name)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
85 rlog = revlog.revlog(tvfs, name)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
86 return rlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
87
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
88
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
89 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
90 '''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
91 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
92 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
93 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
94 nextrev = len(rlog)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
95 p1 = rlog.node(nextrev - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
96 p2 = node.nullid
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
97 if isext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
98 flags = revlog.REVIDX_EXTSTORED
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
99 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
100 flags = revlog.REVIDX_DEFAULT_FLAGS
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
101 # 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
102 rlog._storedeltachains = isdelta
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
103 try:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
104 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
105 return nextrev
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
106 except Exception as ex:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
107 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
108 finally:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
109 # 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
110 rlog._storedeltachains = True
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
111
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
112
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
113 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
114 '''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
115
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
116 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
117 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
118
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
119 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
120 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
121 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
122
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
123 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
124 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
125 '''
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
126
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
127 class dummychangegroup(object):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
128 @staticmethod
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
129 def deltachunk(pnode):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
130 pnode = pnode or node.nullid
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
131 parentrev = rlog.rev(pnode)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
132 r = parentrev + 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
133 if r >= len(rlog):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
134 return {}
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
135 if optimaldelta:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
136 deltaparent = parentrev
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
137 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
138 # suboptimal deltaparent
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
139 deltaparent = min(0, parentrev)
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
140 if not rlog.candelta(deltaparent, r):
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
141 deltaparent = -1
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
142 return {
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
143 b'node': rlog.node(r),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
144 b'p1': pnode,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
145 b'p2': node.nullid,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
146 b'cs': rlog.node(rlog.linkrev(r)),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
147 b'flags': rlog.flags(r),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
148 b'deltabase': rlog.node(deltaparent),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
149 b'delta': rlog.revdiff(deltaparent, r),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
150 }
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
151
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
152 def deltaiter(self):
34148
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
153 chain = None
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
154 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
155 node = chunkdata[b'node']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
156 p1 = chunkdata[b'p1']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
157 p2 = chunkdata[b'p2']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
158 cs = chunkdata[b'cs']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
159 deltabase = chunkdata[b'deltabase']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
160 delta = chunkdata[b'delta']
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
161 flags = chunkdata[b'flags']
34148
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
162
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
163 chain = node
c8b6ed51386b changegroup: remove changegroup dependency from revlog.addgroup
Durham Goode <durham@fb.com>
parents: 33625
diff changeset
164
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
165 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
166
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
167 def linkmap(lnode):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
168 return rlog.rev(lnode)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
169
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
170 dlog = newrevlog(destname, recreate=True)
34291
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
171 dummydeltas = dummychangegroup().deltaiter()
1db9abf407c5 revlog: add revmap back to revlog.addgroup
Durham Goode <durham@fb.com>
parents: 34148
diff changeset
172 dlog.addgroup(dummydeltas, linkmap, tr)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
173 return dlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
174
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
175
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
176 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
177 '''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
178
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
179 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
180 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
181 dlog = newrevlog(destname, recreate=True)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
182 for r in rlog:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
183 p1 = rlog.node(r - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
184 p2 = node.nullid
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
185 if r == 0 or (rlog.flags(r) & revlog.REVIDX_EXTSTORED):
42777
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
186 text = rlog.rawdata(r)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
187 cachedelta = None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
188 else:
36744
33275ab5e837 revlog: do not use delta for lfs revisions
Jun Wu <quark@fb.com>
parents: 35638
diff changeset
189 # deltaparent cannot have EXTSTORED flag.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
190 deltaparent = max(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
191 [-1]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
192 + [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
193 p
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
194 for p in range(r)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
195 if rlog.flags(p) & revlog.REVIDX_EXTSTORED == 0
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
196 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
197 )
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
198 text = None
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
199 cachedelta = (deltaparent, rlog.revdiff(deltaparent, r))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
200 flags = rlog.flags(r)
33625
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
201 ifh = dfh = None
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
202 try:
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
203 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
204 if not dlog._inline:
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
205 dfh = dlog.opener(dlog.datafile, b'a+')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
206 dlog._addrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
207 rlog.node(r), text, tr, r, p1, p2, flags, cachedelta, ifh, dfh
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
208 )
33625
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
209 finally:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
210 if dfh is not None:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
211 dfh.close()
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
212 if ifh is not None:
6788e648efcf test-revlog-raw: close file handles explicitly (issue5644)
Yuya Nishihara <yuya@tcha.org>
parents: 31764
diff changeset
213 ifh.close()
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
214 return dlog
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
215
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
216
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
217 # Utilities to generate revisions for testing
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
218
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
219
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
220 def genbits(n):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
221 '''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
222 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
223
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
224 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
225 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
226 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
227 '''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
228 m = 2 ** n
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 # 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
231 gray = lambda x: x ^ (x >> 1)
31763
8a0c47982ade test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents: 31748
diff changeset
232 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
233
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
234 # 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
235 # 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
236
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
237 # 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
238 a = [0] * m
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 # Iterate from 0.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
241 x = 0
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
242 yield x
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
243 for i in range(m * m):
31763
8a0c47982ade test-revlog-raw: fix "genbits" implementation
Jun Wu <quark@fb.com>
parents: 31748
diff changeset
244 x = reversegray[x]
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
245 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
246 assert a[x] < m
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
247 a[x] += 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
248 x = y
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
249 yield x
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
250
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
251
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
252 def gentext(rev):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
253 '''Given a revision number, generate dummy text'''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
254 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
255
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
256
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
257 def writecases(rlog, tr):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
258 '''Write some revisions interested to the test.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
259
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
260 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
261
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
262 - 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
263 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
264 - 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
265 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
266 interacted with revlog deltas.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
267 - Is its text empty? (isempty)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
268 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
269 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
270 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
271
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
272 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
273 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
274
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
275 len(set(
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
276 (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
277 for r in range(len(rlog) - 1)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
278 )) is 64.
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
279
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
280 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
281 mentioned above.
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 Return expected [(text, rawtext)].
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 result = []
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
286 for i, x in enumerate(genbits(3)):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
287 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
288 if isempty:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
289 text = b''
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
290 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
291 text = gentext(i)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
292 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
293
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
294 # Verify text, rawtext, and rawsize
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
295 if isext:
42988
f4caf910669e flagprocessors: writetransform function take side data as parameter (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42985
diff changeset
296 rawtext = writeprocessor(None, text, {})[0]
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
297 else:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
298 rawtext = text
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
299 if rlog.rawsize(rev) != len(rawtext):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
300 abort('rev %d: wrong rawsize' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
301 if rlog.revision(rev, raw=False) != text:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
302 abort('rev %d: wrong text' % rev)
42777
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
303 if rlog.rawdata(rev) != rawtext:
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
304 abort('rev %d: wrong rawtext' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
305 result.append((text, rawtext))
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
306
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
307 # 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
308 # 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
309 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
310 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
311 if bool(rlog.flags(rev)) != isext:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
312 abort('rev %d: isext is ineffective' % rev)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
313 return result
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
314
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
315
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
316 # Main test and checking
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
317
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
318
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
319 def checkrevlog(rlog, expected):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
320 '''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
321 # 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
322 # depending on revlog caching (see revlog._cache).
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
323 for r0 in range(len(rlog) - 1):
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
324 r1 = r0 + 1
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
325 for revorder in [[r0, r1], [r1, r0]]:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
326 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
327 nlog = newrevlog()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
328 for rev in revorder:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
329 for raw in raworder:
42777
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
330 if raw:
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
331 t = nlog.rawdata(rev)
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
332 else:
740450677221 rawdata: update callers in test-revlog-raw
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42732
diff changeset
333 t = nlog.revision(rev)
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
334 if t != expected[rev][int(raw)]:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
335 abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
336 'rev %d: corrupted %stext'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
337 % (rev, raw and 'raw' or '')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
338 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
339
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
340
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
341 slicingdata = [
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
342 ([0, 1, 2, 3, 55, 56, 58, 59, 60], [[0, 1], [2], [58], [59, 60]], 10),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
343 ([0, 1, 2, 3, 55, 56, 58, 59, 60], [[0, 1], [2], [58], [59, 60]], 10),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
344 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
345 [-1, 0, 1, 2, 3, 55, 56, 58, 59, 60],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
346 [[-1, 0, 1], [2], [58], [59, 60]],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
347 10,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
348 ),
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
349 ]
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
350
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
351
41034
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
352 def slicingtest(rlog):
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
353 oldmin = rlog._srmingapsize
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
354 try:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
355 # 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
356 # slicing is diregarded.
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
357 rlog._srmingapsize = 0
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
358 for item in slicingdata:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
359 chain, expected, target = item
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
360 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
361 result = list(result)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
362 if result != expected:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
363 print('slicing differ:')
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
364 print(' chain: %s' % chain)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
365 print(' target: %s' % target)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
366 print(' expected: %s' % expected)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
367 print(' result: %s' % result)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
368 finally:
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
369 rlog._srmingapsize = oldmin
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
370
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
371
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
372 def md5sum(s):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
373 return hashlib.md5(s).digest()
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
374
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
375
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
376 def _maketext(*coord):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
377 """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
378
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
379 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
380 compressible"""
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
381 pieces = []
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
382 for start, size in coord:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
383 num = range(start, start + size)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
384 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
385 pieces.append(b'\n'.join(p))
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
386 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
387
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
388
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
389 data = [
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
390 _maketext((0, 120), (456, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
391 _maketext((0, 120), (345, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
392 _maketext((0, 120), (734, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
393 _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
394 _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
395 _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
396 _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
397 _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
398 _maketext((0, 120), (123, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
399 _maketext((0, 120), (145, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
400 _maketext((0, 120), (104, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
401 _maketext((0, 120), (430, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
402 _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
403 _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
404 _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
405 _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
406 _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
407 _maketext((0, 120), (249, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
408 _maketext((0, 120), (832, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
409 _maketext((0, 120), (891, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
410 _maketext((0, 120), (543, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
411 _maketext((0, 120), (120, 60)),
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
412 _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
413 _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
414 _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
415 _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
416 _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
417 _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
418 _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
419 _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
420 _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
421 _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
422 ]
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
423
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
424
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
425 def makesnapshot(tr):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
426 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
427 for i in data:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
428 appendrev(rl, i, tr)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
429 return rl
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
430
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
431
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
432 snapshots = [-1, 0, 6, 8, 11, 17, 19, 21, 25, 30]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
433
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
434
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
435 def issnapshottest(rlog):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
436 result = []
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
437 if rlog.issnapshot(-1):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
438 result.append(-1)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
439 for rev in rlog:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
440 if rlog.issnapshot(rev):
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
441 result.append(rev)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
442 if snapshots != result:
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
443 print('snapshot differ:')
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
444 print(' expected: %s' % snapshots)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
445 print(' got: %s' % result)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
446
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
447
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
448 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
449 snapshotmap15 = {0: [17, 19, 25], 8: [21], -1: [30]}
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
450
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
451
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
452 def findsnapshottest(rlog):
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
453 resultall = collections.defaultdict(list)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
454 deltas._findsnapshots(rlog, resultall, 0)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
455 resultall = dict(resultall.items())
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
456 if resultall != snapshotmapall:
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
457 print('snapshot map differ:')
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
458 print(' expected: %s' % snapshotmapall)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
459 print(' got: %s' % resultall)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
460 result15 = collections.defaultdict(list)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
461 deltas._findsnapshots(rlog, result15, 15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
462 result15 = dict(result15.items())
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
463 if result15 != snapshotmap15:
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
464 print('snapshot map differ:')
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
465 print(' expected: %s' % snapshotmap15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
466 print(' got: %s' % result15)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
467
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
468
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
469 def maintest():
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
470 with newtransaction() as tr:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
471 rl = newrevlog(recreate=True)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
472 expected = writecases(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
473 checkrevlog(rl, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
474 print('local test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
475 # Copy via revlog.addgroup
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
476 rl1 = addgroupcopy(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
477 checkrevlog(rl1, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
478 rl2 = addgroupcopy(rl, tr, optimaldelta=False)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
479 checkrevlog(rl2, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
480 print('addgroupcopy test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
481 # Copy via revlog.clone
37896
03a09579c854 tests: port test-revlog-raw.py to Python 3
Augie Fackler <augie@google.com>
parents: 36744
diff changeset
482 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
483 rl.clone(tr, rl3)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
484 checkrevlog(rl3, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
485 print('clone test passed')
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
486 # Copy via low-level revlog._addrevision
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
487 rl4 = lowlevelcopy(rl, tr)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
488 checkrevlog(rl4, expected)
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
489 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
490 slicingtest(rl)
cca12a31ede5 revlog: add some direct testing of the slicing logic
Boris Feld <boris.feld@octobus.net>
parents: 39232
diff changeset
491 print('slicing test passed')
41035
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
492 rl5 = makesnapshot(tr)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
493 issnapshottest(rl5)
15f78383d3c8 revlog: add an explicit test for `issnapshot`
Boris Feld <boris.feld@octobus.net>
parents: 41034
diff changeset
494 print('issnapshot test passed')
41087
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
495 findsnapshottest(rl5)
797a416a91bd revlog: add test case for _findsnapshots
Boris Feld <boris.feld@octobus.net>
parents: 41035
diff changeset
496 print('findsnapshot test passed')
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
497
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42988
diff changeset
498
31748
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
499 try:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
500 maintest()
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
501 except Exception as ex:
985de02b5b9d revlog: add a stronger test for raw processing
Jun Wu <quark@fb.com>
parents:
diff changeset
502 abort('crashed: %s' % ex)