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