Mercurial > hg
comparison tests/test-revlog-raw.py @ 37896:03a09579c854
tests: port test-revlog-raw.py to Python 3
# skip-blame just b prefixes
Differential Revision: https://phab.mercurial-scm.org/D3496
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 27 Apr 2018 10:46:33 -0400 |
parents | 33275ab5e837 |
children | 0a5b20c107a6 |
comparison
equal
deleted
inserted
replaced
37895:e0598133ac68 | 37896:03a09579c854 |
---|---|
11 transaction, | 11 transaction, |
12 vfs, | 12 vfs, |
13 ) | 13 ) |
14 | 14 |
15 # TESTTMP is optional. This makes it convenient to run without run-tests.py | 15 # TESTTMP is optional. This makes it convenient to run without run-tests.py |
16 tvfs = vfs.vfs(encoding.environ.get('TESTTMP', b'/tmp')) | 16 tvfs = vfs.vfs(encoding.environ.get(b'TESTTMP', b'/tmp')) |
17 | 17 |
18 # Enable generaldelta otherwise revlog won't use delta as expected by the test | 18 # Enable generaldelta otherwise revlog won't use delta as expected by the test |
19 tvfs.options = {'generaldelta': True, 'revlogv1': True} | 19 tvfs.options = {b'generaldelta': True, b'revlogv1': True} |
20 | 20 |
21 # The test wants to control whether to use delta explicitly, based on | 21 # The test wants to control whether to use delta explicitly, based on |
22 # "storedeltachains". | 22 # "storedeltachains". |
23 revlog.revlog._isgooddeltainfo = lambda self, d, textlen: self.storedeltachains | 23 revlog.revlog._isgooddeltainfo = lambda self, d, textlen: self.storedeltachains |
24 | 24 |
114 else: | 114 else: |
115 # suboptimal deltaparent | 115 # suboptimal deltaparent |
116 deltaparent = min(0, parentrev) | 116 deltaparent = min(0, parentrev) |
117 if not rlog.candelta(deltaparent, r): | 117 if not rlog.candelta(deltaparent, r): |
118 deltaparent = -1 | 118 deltaparent = -1 |
119 return {'node': rlog.node(r), 'p1': pnode, 'p2': node.nullid, | 119 return {b'node': rlog.node(r), b'p1': pnode, b'p2': node.nullid, |
120 'cs': rlog.node(rlog.linkrev(r)), 'flags': rlog.flags(r), | 120 b'cs': rlog.node(rlog.linkrev(r)), b'flags': rlog.flags(r), |
121 'deltabase': rlog.node(deltaparent), | 121 b'deltabase': rlog.node(deltaparent), |
122 'delta': rlog.revdiff(deltaparent, r)} | 122 b'delta': rlog.revdiff(deltaparent, r)} |
123 | 123 |
124 def deltaiter(self): | 124 def deltaiter(self): |
125 chain = None | 125 chain = None |
126 for chunkdata in iter(lambda: self.deltachunk(chain), {}): | 126 for chunkdata in iter(lambda: self.deltachunk(chain), {}): |
127 node = chunkdata['node'] | 127 node = chunkdata[b'node'] |
128 p1 = chunkdata['p1'] | 128 p1 = chunkdata[b'p1'] |
129 p2 = chunkdata['p2'] | 129 p2 = chunkdata[b'p2'] |
130 cs = chunkdata['cs'] | 130 cs = chunkdata[b'cs'] |
131 deltabase = chunkdata['deltabase'] | 131 deltabase = chunkdata[b'deltabase'] |
132 delta = chunkdata['delta'] | 132 delta = chunkdata[b'delta'] |
133 flags = chunkdata['flags'] | 133 flags = chunkdata[b'flags'] |
134 | 134 |
135 chain = node | 135 chain = node |
136 | 136 |
137 yield (node, p1, p2, cs, deltabase, delta, flags) | 137 yield (node, p1, p2, cs, deltabase, delta, flags) |
138 | 138 |
164 text = None | 164 text = None |
165 cachedelta = (deltaparent, rlog.revdiff(deltaparent, r)) | 165 cachedelta = (deltaparent, rlog.revdiff(deltaparent, r)) |
166 flags = rlog.flags(r) | 166 flags = rlog.flags(r) |
167 ifh = dfh = None | 167 ifh = dfh = None |
168 try: | 168 try: |
169 ifh = dlog.opener(dlog.indexfile, 'a+') | 169 ifh = dlog.opener(dlog.indexfile, b'a+') |
170 if not dlog._inline: | 170 if not dlog._inline: |
171 dfh = dlog.opener(dlog.datafile, 'a+') | 171 dfh = dlog.opener(dlog.datafile, b'a+') |
172 dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, | 172 dlog._addrevision(rlog.node(r), text, tr, r, p1, p2, flags, |
173 cachedelta, ifh, dfh) | 173 cachedelta, ifh, dfh) |
174 finally: | 174 finally: |
175 if dfh is not None: | 175 if dfh is not None: |
176 dfh.close() | 176 dfh.close() |
303 checkrevlog(rl1, expected) | 303 checkrevlog(rl1, expected) |
304 rl2 = addgroupcopy(rl, tr, optimaldelta=False) | 304 rl2 = addgroupcopy(rl, tr, optimaldelta=False) |
305 checkrevlog(rl2, expected) | 305 checkrevlog(rl2, expected) |
306 print('addgroupcopy test passed') | 306 print('addgroupcopy test passed') |
307 # Copy via revlog.clone | 307 # Copy via revlog.clone |
308 rl3 = newrevlog(name='_destrevlog3.i', recreate=True) | 308 rl3 = newrevlog(name=b'_destrevlog3.i', recreate=True) |
309 rl.clone(tr, rl3) | 309 rl.clone(tr, rl3) |
310 checkrevlog(rl3, expected) | 310 checkrevlog(rl3, expected) |
311 print('clone test passed') | 311 print('clone test passed') |
312 # Copy via low-level revlog._addrevision | 312 # Copy via low-level revlog._addrevision |
313 rl4 = lowlevelcopy(rl, tr) | 313 rl4 = lowlevelcopy(rl, tr) |