##// END OF EJS Templates
rust-index: renamed `MixedIndex` as `Index`...
Georges Racinet on incendie.racinet.fr -
r52147:f94c1033 default
parent child Browse files
Show More
@@ -225,9 +225,9 b' else:'
225 225 parse_index_v1_nodemap = None
226 226
227 227
228 def parse_index_v1_mixed(data, inline, default_header):
228 def parse_index_v1_rust(data, inline, default_header):
229 229 cache = (0, data) if inline else None
230 return rustrevlog.MixedIndex(data, default_header), cache
230 return rustrevlog.Index(data, default_header), cache
231 231
232 232
233 233 # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte
@@ -1699,7 +1699,7 b' class revlog:'
1699 1699 self._parse_index = parse_index_v1_nodemap
1700 1700 elif use_rust_index:
1701 1701 self._parse_index = functools.partial(
1702 parse_index_v1_mixed, default_header=new_header
1702 parse_index_v1_rust, default_header=new_header
1703 1703 )
1704 1704 try:
1705 1705 d = self._parse_index(index_data, self._inline)
@@ -30,9 +30,11 b' except ImportError:'
30 30 cparsers = None
31 31
32 32 try:
33 from ..rustext.revlog import MixedIndex # pytype: disable=import-error
33 from ..rustext.revlog import ( # pytype: disable=import-error
34 Index as RustIndex,
35 )
34 36 except ImportError:
35 MixedIndex = None
37 RustIndex = None
36 38
37 39
38 40 @unittest.skipIf(
@@ -47,7 +49,7 b' class RevlogBasedTestBase(unittest.TestC'
47 49
48 50
49 51 @unittest.skipIf(
50 MixedIndex is None,
52 RustIndex is None,
51 53 'The Rust index is not available. It is needed for this test.',
52 54 )
53 55 class RustRevlogBasedTestBase(unittest.TestCase):
@@ -57,4 +59,4 b' class RustRevlogBasedTestBase(unittest.T'
57 59 # not inheriting RevlogBasedTestCase to avoid having a
58 60 # `parseindex` method that would be shadowed by future subclasses
59 61 # this duplication will soon be removed
60 return MixedIndex(data, REVLOGV1)
62 return RustIndex(data, REVLOGV1)
@@ -40,7 +40,7 b' pub(crate) fn py_rust_index_to_graph('
40 40 py: Python,
41 41 index: PyObject,
42 42 ) -> PyResult<UnsafePyLeaked<PySharedIndex>> {
43 let midx = index.extract::<MixedIndex>(py)?;
43 let midx = index.extract::<Index>(py)?;
44 44 let leaked = midx.index(py).leak_immutable();
45 45 Ok(unsafe { leaked.map(py, |idx| PySharedIndex { inner: idx }) })
46 46 }
@@ -85,7 +85,7 b' impl RevlogIndex for PySharedIndex {'
85 85 }
86 86 }
87 87
88 py_class!(pub class MixedIndex |py| {
88 py_class!(pub class Index |py| {
89 89 @shared data index: hg::index::Index;
90 90 data nt: RefCell<Option<CoreNodeTree>>;
91 91 data docket: RefCell<Option<PyObject>>;
@@ -98,7 +98,7 b' py_class!(pub class MixedIndex |py| {'
98 98 _cls,
99 99 data: PyObject,
100 100 default_header: u32,
101 ) -> PyResult<MixedIndex> {
101 ) -> PyResult<Self> {
102 102 Self::new(py, data, default_header)
103 103 }
104 104
@@ -598,8 +598,8 b" impl<'p> SnapshotsCache for PySnapshotsC"
598 598 }
599 599 }
600 600
601 impl MixedIndex {
602 fn new(py: Python, data: PyObject, header: u32) -> PyResult<MixedIndex> {
601 impl Index {
602 fn new(py: Python, data: PyObject, header: u32) -> PyResult<Self> {
603 603 // Safety: we keep the buffer around inside the class as `index_mmap`
604 604 let (buf, bytes) = unsafe { mmap_keeparound(py, data)? };
605 605
@@ -1108,7 +1108,7 b' pub fn init_module(py: Python, package: '
1108 1108 m.add(py, "__package__", package)?;
1109 1109 m.add(py, "__doc__", "RevLog - Rust implementations")?;
1110 1110
1111 m.add_class::<MixedIndex>(py)?;
1111 m.add_class::<Index>(py)?;
1112 1112 m.add_class::<NodeTree>(py)?;
1113 1113
1114 1114 let sys = PyModule::import(py, "sys")?;
@@ -27,16 +27,16 b' header = struct.unpack(">I", revlogtesti'
27 27 class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase):
28 28 def test_heads(self):
29 29 idx = self.parseindex()
30 rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header)
30 rustidx = revlog.Index(revlogtesting.data_non_inlined, header)
31 31 self.assertEqual(rustidx.headrevs(), idx.headrevs())
32 32
33 33 def test_len(self):
34 34 idx = self.parseindex()
35 rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header)
35 rustidx = revlog.Index(revlogtesting.data_non_inlined, header)
36 36 self.assertEqual(len(rustidx), len(idx))
37 37
38 38 def test_ancestors(self):
39 rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header)
39 rustidx = revlog.Index(revlogtesting.data_non_inlined, header)
40 40 lazy = LazyAncestors(rustidx, [3], 0, True)
41 41 # we have two more references to the index:
42 42 # - in its inner iterator for __contains__ and __bool__
General Comments 0
You need to be logged in to leave comments. Login now