##// END OF EJS Templates
rust-index: add a struct wrapping the C index...
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

File last commit:

r44413:b69d5f3a default
r44413:b69d5f3a default
Show More
test-rust-revlog.py
34 lines | 851 B | text/x-python | PythonLexer
from __future__ import absolute_import
import unittest
try:
from mercurial import rustext
rustext.__name__ # trigger immediate actual import
except ImportError:
rustext = None
else:
from mercurial.rustext import revlog
from mercurial.testing import revlog as revlogtesting
@unittest.skipIf(
rustext is None, "rustext module revlog relies on is not available",
)
class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase):
def test_heads(self):
idx = self.parseindex()
rustidx = revlog.MixedIndex(idx)
self.assertEqual(rustidx.headrevs(), idx.headrevs())
def test_len(self):
idx = self.parseindex()
rustidx = revlog.MixedIndex(idx)
self.assertEqual(len(rustidx), len(idx))
if __name__ == '__main__':
import silenttestrunner
silenttestrunner.main(__name__)