comparison tests/test-rust-revlog.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 b69d5f3a41d0
children 443dc1655923
comparison
equal deleted inserted replaced
44010:2728fcb8127c 44011:c627f1b2f3c3
7 rustext.__name__ # trigger immediate actual import 7 rustext.__name__ # trigger immediate actual import
8 except ImportError: 8 except ImportError:
9 rustext = None 9 rustext = None
10 else: 10 else:
11 from mercurial.rustext import revlog 11 from mercurial.rustext import revlog
12
13 # this would fail already without appropriate ancestor.__package__
14 from mercurial.rustext.ancestor import LazyAncestors
12 15
13 from mercurial.testing import revlog as revlogtesting 16 from mercurial.testing import revlog as revlogtesting
14 17
15 18
16 @unittest.skipIf( 19 @unittest.skipIf(
25 def test_len(self): 28 def test_len(self):
26 idx = self.parseindex() 29 idx = self.parseindex()
27 rustidx = revlog.MixedIndex(idx) 30 rustidx = revlog.MixedIndex(idx)
28 self.assertEqual(len(rustidx), len(idx)) 31 self.assertEqual(len(rustidx), len(idx))
29 32
33 def test_ancestors(self):
34 idx = self.parseindex()
35 rustidx = revlog.MixedIndex(idx)
36 lazy = LazyAncestors(rustidx, [3], 0, True)
37 # we have two more references to the index:
38 # - in its inner iterator for __contains__ and __bool__
39 # - in the LazyAncestors instance itself (to spawn new iterators)
40 self.assertTrue(2 in lazy)
41 self.assertTrue(bool(lazy))
42 self.assertEqual(list(lazy), [3, 2, 1, 0])
43 # a second time to validate that we spawn new iterators
44 self.assertEqual(list(lazy), [3, 2, 1, 0])
45
46 # let's check bool for an empty one
47 self.assertFalse(LazyAncestors(idx, [0], 0, False))
48
30 49
31 if __name__ == '__main__': 50 if __name__ == '__main__':
32 import silenttestrunner 51 import silenttestrunner
33 52
34 silenttestrunner.main(__name__) 53 silenttestrunner.main(__name__)