D8159: rust-nodemap: add binding for `nodemap_data_incremental`

2020-02-26 Thread Raphaël Gomès
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8159

AFFECTED FILES
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

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
@@ -15,7 +15,7 @@
 PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::{
-nodemap::{NodeMapError, NodeTree},
+nodemap::{Block, NodeMapError, NodeTree},
 revlog::{nodemap::NodeMap, RevlogIndex},
 NodeError, Revision,
 };
@@ -35,6 +35,7 @@
 py_class!(pub class MixedIndex |py| {
 data cindex: RefCell;
 data nt: RefCell>;
+data docket: RefCell>;
 
 def __new__(_cls, cindex: PyObject) -> PyResult {
 Self::new(py, cindex)
@@ -255,6 +256,9 @@
 self.inner_nodemap_data_all(py)
 }
 
+def nodemap_data_incremental(&self) -> PyResult {
+self.inner_nodemap_data_incremental(py)
+}
 
 });
 
@@ -264,6 +268,7 @@
 py,
 RefCell::new(cindex::Index::new(py, cindex)?),
 RefCell::new(None),
+RefCell::new(None),
 )
 }
 
@@ -338,6 +343,28 @@
 let bytes = PyBytes::new(py, &bytes);
 Ok(bytes)
 }
+
+/// Returns the last saved docket along with the size of any changed data
+/// (in number of blocks), and said data as bytes.
+fn inner_nodemap_data_incremental(
+&self,
+py: Python,
+) -> PyResult {
+let docket = self.docket(py).borrow();
+let docket = match docket.as_ref() {
+Some(d) => d,
+None => return Ok(py.None()),
+};
+
+let node_tree = self.get_nodetree(py)?.borrow_mut().take().unwrap();
+let masked_blocks = node_tree.masked_readonly_blocks();
+let (_, data) = node_tree.into_readonly_and_added_bytes();
+let changed = masked_blocks * std::mem::size_of::();
+
+Ok((docket, changed, PyBytes::new(py, &data))
+.to_py_object(py)
+.into_object())
+}
 }
 
 fn revlog_error(py: Python) -> PyErr {



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8159: rust-nodemap: add binding for `nodemap_data_incremental`

2020-02-28 Thread marmoute (Pierre-Yves David)
marmoute updated this revision to Diff 20378.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8159?vs=20334&id=20378

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8159/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8159

AFFECTED FILES
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

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
@@ -15,7 +15,7 @@
 PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::{
-nodemap::{NodeMapError, NodeTree},
+nodemap::{Block, NodeMapError, NodeTree},
 revlog::{nodemap::NodeMap, RevlogIndex},
 NodeError, Revision,
 };
@@ -35,6 +35,7 @@
 py_class!(pub class MixedIndex |py| {
 data cindex: RefCell;
 data nt: RefCell>;
+data docket: RefCell>;
 
 def __new__(_cls, cindex: PyObject) -> PyResult {
 Self::new(py, cindex)
@@ -264,6 +265,9 @@
 self.inner_nodemap_data_all(py)
 }
 
+def nodemap_data_incremental(&self) -> PyResult {
+self.inner_nodemap_data_incremental(py)
+}
 
 });
 
@@ -273,6 +277,7 @@
 py,
 RefCell::new(cindex::Index::new(py, cindex)?),
 RefCell::new(None),
+RefCell::new(None),
 )
 }
 
@@ -347,6 +352,28 @@
 let bytes = PyBytes::new(py, &bytes);
 Ok(bytes)
 }
+
+/// Returns the last saved docket along with the size of any changed data
+/// (in number of blocks), and said data as bytes.
+fn inner_nodemap_data_incremental(
+&self,
+py: Python,
+) -> PyResult {
+let docket = self.docket(py).borrow();
+let docket = match docket.as_ref() {
+Some(d) => d,
+None => return Ok(py.None()),
+};
+
+let node_tree = self.get_nodetree(py)?.borrow_mut().take().unwrap();
+let masked_blocks = node_tree.masked_readonly_blocks();
+let (_, data) = node_tree.into_readonly_and_added_bytes();
+let changed = masked_blocks * std::mem::size_of::();
+
+Ok((docket, changed, PyBytes::new(py, &data))
+.to_py_object(py)
+.into_object())
+}
 }
 
 fn revlog_error(py: Python) -> PyErr {



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8159: rust-nodemap: add binding for `nodemap_data_incremental`

2020-03-10 Thread Raphaël Gomès
Alphare updated this revision to Diff 20658.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8159?vs=20378&id=20658

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8159/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8159

AFFECTED FILES
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

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
@@ -15,7 +15,7 @@
 PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::{
-nodemap::{NodeMapError, NodeTree},
+nodemap::{Block, NodeMapError, NodeTree},
 revlog::{nodemap::NodeMap, RevlogIndex},
 NodeError, Revision,
 };
@@ -35,6 +35,7 @@
 py_class!(pub class MixedIndex |py| {
 data cindex: RefCell;
 data nt: RefCell>;
+data docket: RefCell>;
 
 def __new__(_cls, cindex: PyObject) -> PyResult {
 Self::new(py, cindex)
@@ -264,6 +265,9 @@
 self.inner_nodemap_data_all(py)
 }
 
+def nodemap_data_incremental(&self) -> PyResult {
+self.inner_nodemap_data_incremental(py)
+}
 
 });
 
@@ -273,6 +277,7 @@
 py,
 RefCell::new(cindex::Index::new(py, cindex)?),
 RefCell::new(None),
+RefCell::new(None),
 )
 }
 
@@ -347,6 +352,28 @@
 let bytes = PyBytes::new(py, &bytes);
 Ok(bytes)
 }
+
+/// Returns the last saved docket along with the size of any changed data
+/// (in number of blocks), and said data as bytes.
+fn inner_nodemap_data_incremental(
+&self,
+py: Python,
+) -> PyResult {
+let docket = self.docket(py).borrow();
+let docket = match docket.as_ref() {
+Some(d) => d,
+None => return Ok(py.None()),
+};
+
+let node_tree = self.get_nodetree(py)?.borrow_mut().take().unwrap();
+let masked_blocks = node_tree.masked_readonly_blocks();
+let (_, data) = node_tree.into_readonly_and_added_bytes();
+let changed = masked_blocks * std::mem::size_of::();
+
+Ok((docket, changed, PyBytes::new(py, &data))
+.to_py_object(py)
+.into_object())
+}
 }
 
 fn revlog_error(py: Python) -> PyErr {



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8159: rust-nodemap: add binding for `nodemap_data_incremental`

2020-03-11 Thread gracinet (Georges Racinet)
Closed by commit rHG5bbf887275b0: rust-nodemap: add binding for 
`nodemap_data_incremental` (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/D8159?vs=20658&id=20697

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8159/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8159

AFFECTED FILES
  rust/hg-cpython/src/revlog.rs

CHANGE DETAILS

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
@@ -15,7 +15,7 @@
 PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject,
 };
 use hg::{
-nodemap::{NodeMapError, NodeTree},
+nodemap::{Block, NodeMapError, NodeTree},
 revlog::{nodemap::NodeMap, RevlogIndex},
 NodeError, Revision,
 };
@@ -35,6 +35,7 @@
 py_class!(pub class MixedIndex |py| {
 data cindex: RefCell;
 data nt: RefCell>;
+data docket: RefCell>;
 
 def __new__(_cls, cindex: PyObject) -> PyResult {
 Self::new(py, cindex)
@@ -264,6 +265,9 @@
 self.inner_nodemap_data_all(py)
 }
 
+def nodemap_data_incremental(&self) -> PyResult {
+self.inner_nodemap_data_incremental(py)
+}
 
 });
 
@@ -273,6 +277,7 @@
 py,
 RefCell::new(cindex::Index::new(py, cindex)?),
 RefCell::new(None),
+RefCell::new(None),
 )
 }
 
@@ -347,6 +352,28 @@
 let bytes = PyBytes::new(py, &bytes);
 Ok(bytes)
 }
+
+/// Returns the last saved docket along with the size of any changed data
+/// (in number of blocks), and said data as bytes.
+fn inner_nodemap_data_incremental(
+&self,
+py: Python,
+) -> PyResult {
+let docket = self.docket(py).borrow();
+let docket = match docket.as_ref() {
+Some(d) => d,
+None => return Ok(py.None()),
+};
+
+let node_tree = self.get_nodetree(py)?.borrow_mut().take().unwrap();
+let masked_blocks = node_tree.masked_readonly_blocks();
+let (_, data) = node_tree.into_readonly_and_added_bytes();
+let changed = masked_blocks * std::mem::size_of::();
+
+Ok((docket, changed, PyBytes::new(py, &data))
+.to_py_object(py)
+.into_object())
+}
 }
 
 fn revlog_error(py: Python) -> PyErr {



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel