rust/hg-cpython/src/dirstate/dirstate_map.rs
changeset 48392 434de12918fd
parent 48260 269ff8978086
child 48416 c1b633db67fc
equal deleted inserted replaced
48391:b80e5e75d51e 48392:434de12918fd
    16     PyResult, Python, PythonObject, ToPyObject, UnsafePyLeaked,
    16     PyResult, Python, PythonObject, ToPyObject, UnsafePyLeaked,
    17 };
    17 };
    18 
    18 
    19 use crate::{
    19 use crate::{
    20     dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
    20     dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
    21     dirstate::item::{timestamp, DirstateItem},
    21     dirstate::item::DirstateItem,
    22     pybytes_deref::PyBytesDeref,
    22     pybytes_deref::PyBytesDeref,
    23 };
    23 };
    24 use hg::{
    24 use hg::{
    25     dirstate::StateMapIter,
    25     dirstate::StateMapIter,
    26     dirstate_tree::dirstate_map::DirstateMap as TreeDirstateMap,
    26     dirstate_tree::dirstate_map::DirstateMap as TreeDirstateMap,
   192 
   192 
   193     def write_v1(
   193     def write_v1(
   194         &self,
   194         &self,
   195         p1: PyObject,
   195         p1: PyObject,
   196         p2: PyObject,
   196         p2: PyObject,
   197         now: (u32, u32)
       
   198     ) -> PyResult<PyBytes> {
   197     ) -> PyResult<PyBytes> {
   199         let now = timestamp(py, now)?;
       
   200 
       
   201         let mut inner = self.inner(py).borrow_mut();
   198         let mut inner = self.inner(py).borrow_mut();
   202         let parents = DirstateParents {
   199         let parents = DirstateParents {
   203             p1: extract_node_id(py, &p1)?,
   200             p1: extract_node_id(py, &p1)?,
   204             p2: extract_node_id(py, &p2)?,
   201             p2: extract_node_id(py, &p2)?,
   205         };
   202         };
   206         let result = inner.pack_v1(parents, now);
   203         let result = inner.pack_v1(parents);
   207         match result {
   204         match result {
   208             Ok(packed) => Ok(PyBytes::new(py, &packed)),
   205             Ok(packed) => Ok(PyBytes::new(py, &packed)),
   209             Err(_) => Err(PyErr::new::<exc::OSError, _>(
   206             Err(_) => Err(PyErr::new::<exc::OSError, _>(
   210                 py,
   207                 py,
   211                 "Dirstate error".to_string(),
   208                 "Dirstate error".to_string(),
   216     /// Returns new data together with whether that data should be appended to
   213     /// Returns new data together with whether that data should be appended to
   217     /// the existing data file whose content is at `self.on_disk` (True),
   214     /// the existing data file whose content is at `self.on_disk` (True),
   218     /// instead of written to a new data file (False).
   215     /// instead of written to a new data file (False).
   219     def write_v2(
   216     def write_v2(
   220         &self,
   217         &self,
   221         now: (u32, u32),
       
   222         can_append: bool,
   218         can_append: bool,
   223     ) -> PyResult<PyObject> {
   219     ) -> PyResult<PyObject> {
   224         let now = timestamp(py, now)?;
       
   225 
       
   226         let mut inner = self.inner(py).borrow_mut();
   220         let mut inner = self.inner(py).borrow_mut();
   227         let result = inner.pack_v2(now, can_append);
   221         let result = inner.pack_v2(can_append);
   228         match result {
   222         match result {
   229             Ok((packed, tree_metadata, append)) => {
   223             Ok((packed, tree_metadata, append)) => {
   230                 let packed = PyBytes::new(py, &packed);
   224                 let packed = PyBytes::new(py, &packed);
   231                 let tree_metadata = PyBytes::new(py, &tree_metadata);
   225                 let tree_metadata = PyBytes::new(py, &tree_metadata);
   232                 let tuple = (packed, tree_metadata, append);
   226                 let tuple = (packed, tree_metadata, append);