D7658: rust-index: expose a method to retrieve the C index
Closed by commit rHG443dc1655923: rust-index: expose a method to retrieve the C index (authored by gracinet). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7658?vs=18942=19082 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7658/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7658 AFFECTED FILES rust/hg-cpython/src/revlog.rs tests/test-rust-revlog.py CHANGE DETAILS diff --git a/tests/test-rust-revlog.py b/tests/test-rust-revlog.py --- a/tests/test-rust-revlog.py +++ b/tests/test-rust-revlog.py @@ -25,6 +25,13 @@ rustidx = revlog.MixedIndex(idx) self.assertEqual(rustidx.headrevs(), idx.headrevs()) +def test_get_cindex(self): +# drop me once we no longer need the method for shortest node +idx = self.parseindex() +rustidx = revlog.MixedIndex(idx) +cidx = rustidx.get_cindex() +self.assertTrue(idx is cidx) + def test_len(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -29,6 +29,17 @@ cindex::Index::new(py, cindex)?)) } +/// Compatibility layer used for Python consumers needing access to the C index +/// +/// Only use case so far is `scmutil.shortesthexnodeidprefix`, +/// that may need to build a custom `nodetree`, based on a specified revset. +/// With a Rust implementation of the nodemap, we will be able to get rid of +/// this, by exposing our own standalone nodemap class, +/// ready to accept `MixedIndex`. +def get_cindex() -> PyResult { +Ok(self.cindex(py).borrow().inner().clone_ref(py)) +} + // Reforwarded C index API To: marmoute, #hg-reviewers, Alphare Cc: durin42, kevincox, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7658: rust-index: expose a method to retrieve the C index
marmoute updated this revision to Diff 18942. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7658?vs=18891=18942 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7658/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7658 AFFECTED FILES rust/hg-cpython/src/revlog.rs tests/test-rust-revlog.py CHANGE DETAILS diff --git a/tests/test-rust-revlog.py b/tests/test-rust-revlog.py --- a/tests/test-rust-revlog.py +++ b/tests/test-rust-revlog.py @@ -25,6 +25,13 @@ rustidx = revlog.MixedIndex(idx) self.assertEqual(rustidx.headrevs(), idx.headrevs()) +def test_get_cindex(self): +# drop me once we no longer need the method for shortest node +idx = self.parseindex() +rustidx = revlog.MixedIndex(idx) +cidx = rustidx.get_cindex() +self.assertTrue(idx is cidx) + def test_len(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -29,6 +29,17 @@ cindex::Index::new(py, cindex)?)) } +/// Compatibility layer used for Python consumers needing access to the C index +/// +/// Only use case so far is `scmutil.shortesthexnodeidprefix`, +/// that may need to build a custom `nodetree`, based on a specified revset. +/// With a Rust implementation of the nodemap, we will be able to get rid of +/// this, by exposing our own standalone nodemap class, +/// ready to accept `MixedIndex`. +def get_cindex() -> PyResult { +Ok(self.cindex(py).borrow().inner().clone_ref(py)) +} + // Reforwarded C index API To: marmoute, #hg-reviewers, Alphare Cc: durin42, kevincox, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7658: rust-index: expose a method to retrieve the C index
marmoute updated this revision to Diff 18891. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7658?vs=18704=18891 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7658/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7658 AFFECTED FILES rust/hg-cpython/src/revlog.rs tests/test-rust-revlog.py CHANGE DETAILS diff --git a/tests/test-rust-revlog.py b/tests/test-rust-revlog.py --- a/tests/test-rust-revlog.py +++ b/tests/test-rust-revlog.py @@ -25,6 +25,13 @@ rustidx = revlog.MixedIndex(idx) self.assertEqual(rustidx.headrevs(), idx.headrevs()) +def test_get_cindex(self): +# drop me once we no longer need the method for shortest node +idx = self.parseindex() +rustidx = revlog.MixedIndex(idx) +cidx = rustidx.get_cindex() +self.assertTrue(idx is cidx) + def test_len(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -32,6 +32,17 @@ cindex::Index::new(py, cindex)?)) } +/// Compatibility layer used for Python consumers needing access to the C index +/// +/// Only use case so far is `scmutil.shortesthexnodeidprefix`, +/// that may need to build a custom `nodetree`, based on a specified revset. +/// With a Rust implementation of the nodemap, we will be able to get rid of +/// this, by exposing our own standalone nodemap class, +/// ready to accept `MixedIndex`. +def get_cindex() -> PyResult { +Ok(self.cindex(py).borrow().inner().clone_ref(py)) +} + // Reforwarded C index API To: marmoute, #hg-reviewers Cc: durin42, kevincox, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D7658: rust-index: expose a method to retrieve the C index
marmoute created this revision. Herald added subscribers: mercurial-devel, mjpieters, kevincox, durin42. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The code for `shortesthexnodeidprefix` need to access the actual C index. For now we grant its wish and expose a method to do so. Once we have the nodemap in Rust, we will be able to implement the same feature from rust and we will be able to drop this method. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7658 AFFECTED FILES rust/hg-cpython/src/revlog.rs tests/test-rust-revlog.py CHANGE DETAILS diff --git a/tests/test-rust-revlog.py b/tests/test-rust-revlog.py --- a/tests/test-rust-revlog.py +++ b/tests/test-rust-revlog.py @@ -25,6 +25,13 @@ rustidx = revlog.MixedIndex(idx) self.assertEqual(rustidx.headrevs(), idx.headrevs()) +def test_get_cindex(self): +# drop me once we no longer need the method for shortest node +idx = self.parseindex() +rustidx = revlog.MixedIndex(idx) +cidx = rustidx.get_cindex() +self.assertTrue(idx is cidx) + def test_len(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -29,6 +29,17 @@ cindex::Index::new(py, cindex)?)) } +/// Compatibility layer used for Python consumers needing access to the C index +/// +/// Only use case so far is `scmutil.shortesthexnodeidprefix`, +/// that may need to build a custom `nodetree`, based on a specified revset. +/// With a Rust implementation of the nodemap, we will be able to get rid of +/// this, by exposing our own standalone nodemap class, +/// ready to accept `MixedIndex`. +def get_cindex() -> PyResult { +Ok(self.cindex(py).borrow().inner().clone_ref(py)) +} + // Reforwarded C index API To: marmoute, #hg-reviewers Cc: durin42, kevincox, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel