comparison tests/test-rust-revlog.py @ 43961:b69d5f3a41d0

rust-index: add a struct wrapping the C index Implementing the full index logic in one go is journey larger than we would like. To achieve a smoother transition, we start with a simple Rust wrapper that delegates allwork to the current C implementation. Once we will have a fully working index object in Rust, we can easily start using more and more Rust Code with it. The object in this patch is functional and tested. However, multiple of the currently existing rust (in the `hg-cpython` crate) requires a `Graph`. Right now we build this `Graph` (as cindex::Index) using the C index passed as a PyObject. They will have to be updated to be made compatible. Differential Revision: https://phab.mercurial-scm.org/D7655
author Georges Racinet <georges.racinet@octobus.net>
date Mon, 23 Dec 2019 10:02:50 -0800
parents
children c627f1b2f3c3
comparison
equal deleted inserted replaced
43960:ab3fd8077f5e 43961:b69d5f3a41d0
1 from __future__ import absolute_import
2 import unittest
3
4 try:
5 from mercurial import rustext
6
7 rustext.__name__ # trigger immediate actual import
8 except ImportError:
9 rustext = None
10 else:
11 from mercurial.rustext import revlog
12
13 from mercurial.testing import revlog as revlogtesting
14
15
16 @unittest.skipIf(
17 rustext is None, "rustext module revlog relies on is not available",
18 )
19 class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase):
20 def test_heads(self):
21 idx = self.parseindex()
22 rustidx = revlog.MixedIndex(idx)
23 self.assertEqual(rustidx.headrevs(), idx.headrevs())
24
25 def test_len(self):
26 idx = self.parseindex()
27 rustidx = revlog.MixedIndex(idx)
28 self.assertEqual(len(rustidx), len(idx))
29
30
31 if __name__ == '__main__':
32 import silenttestrunner
33
34 silenttestrunner.main(__name__)