rust/hg-pyo3/src/revlog/mod.rs
changeset 52828 e49794d16657
parent 52826 9dcba9b379cb
child 52829 c82f64877055
equal deleted inserted replaced
52827:50c0c74ca266 52828:e49794d16657
    50     revision::{
    50     revision::{
    51         check_revision, rev_pyiter_collect, rev_pyiter_collect_or_else,
    51         check_revision, rev_pyiter_collect, rev_pyiter_collect_or_else,
    52         revs_py_list, revs_py_set, PyRevision,
    52         revs_py_list, revs_py_set, PyRevision,
    53     },
    53     },
    54     store::PyFnCache,
    54     store::PyFnCache,
       
    55     transaction::PyTransaction,
    55     util::{new_submodule, take_buffer_with_slice, with_pybytes_buffer},
    56     util::{new_submodule, take_buffer_with_slice, with_pybytes_buffer},
    56 };
    57 };
    57 
    58 
    58 mod config;
    59 mod config;
    59 use config::*;
    60 use config::*;
   388                 py_bytes = with_pybytes_buffer(py, size, f)?;
   389                 py_bytes = with_pybytes_buffer(py, size, f)?;
   389                 Ok(())
   390                 Ok(())
   390             })
   391             })
   391             .map_err(revlog_error_from_msg)?;
   392             .map_err(revlog_error_from_msg)?;
   392             Ok(py_bytes)
   393             Ok(py_bytes)
       
   394         })
       
   395     }
       
   396 
       
   397     #[allow(clippy::too_many_arguments)]
       
   398     #[pyo3(signature = (
       
   399         transaction,
       
   400         entry,
       
   401         data,
       
   402         _link,
       
   403         offset,
       
   404         _sidedata,
       
   405         _sidedata_offset,
       
   406         index_end,
       
   407         data_end,
       
   408         _sidedata_end
       
   409     ))]
       
   410     fn write_entry(
       
   411         slf: &Bound<'_, Self>,
       
   412         py: Python<'_>,
       
   413         transaction: PyObject,
       
   414         entry: &Bound<'_, PyBytes>,
       
   415         data: &Bound<'_, PyTuple>,
       
   416         // TODO remove and also from Python
       
   417         _link: PyObject,
       
   418         offset: usize,
       
   419         // Other underscore args are for revlog-v2, which is unimplemented
       
   420         _sidedata: PyObject,
       
   421         _sidedata_offset: u64,
       
   422         index_end: Option<u64>,
       
   423         data_end: Option<u64>,
       
   424         _sidedata_end: Option<u64>,
       
   425     ) -> PyResult<Py<PyTuple>> {
       
   426         Self::with_core_write(slf, |_self_ref, mut irl| {
       
   427             let transaction = PyTransaction::new(transaction);
       
   428             let header = data.get_borrowed_item(0)?;
       
   429             let header = header.downcast::<PyBytes>()?;
       
   430             let data = data.get_borrowed_item(1)?;
       
   431             let data = data.downcast::<PyBytes>()?;
       
   432             let (idx_pos, data_pos) = irl
       
   433                 .write_entry(
       
   434                     transaction,
       
   435                     entry.as_bytes(),
       
   436                     (header.as_bytes(), data.as_bytes()),
       
   437                     offset,
       
   438                     index_end,
       
   439                     data_end,
       
   440                 )
       
   441                 .map_err(revlog_error_from_msg)?;
       
   442             let tuple = PyTuple::new(
       
   443                 py,
       
   444                 [idx_pos.into_py_any(py)?, data_pos.into_py_any(py)?],
       
   445             )?;
       
   446             Ok(tuple.unbind())
   393         })
   447         })
   394     }
   448     }
   395 
   449 
   396     fn delay(
   450     fn delay(
   397         slf: &Bound<'_, Self>,
   451         slf: &Bound<'_, Self>,