mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
bindings: use pycell instead of mincode for pull data
Reviewed By: quark-zju Differential Revision: D29474445 fbshipit-source-id: dd6536bdbac6e5690c918a222bf3823537ceffcc
This commit is contained in:
parent
b3187fa74a
commit
7ad57c10a5
@ -9,10 +9,11 @@ use crate::dagalgo::dagalgo;
|
||||
use crate::idmap;
|
||||
use crate::Names;
|
||||
use crate::Spans;
|
||||
use anyhow::Result;
|
||||
use anyhow::{format_err, Result};
|
||||
use async_runtime::try_block_unless_interrupted as block_on;
|
||||
use cpython::*;
|
||||
use cpython_ext::convert::BytesLike;
|
||||
use cpython_ext::pycell;
|
||||
use cpython_ext::ExtractInner;
|
||||
use cpython_ext::PyNone;
|
||||
use cpython_ext::PyPath;
|
||||
@ -126,14 +127,14 @@ py_class!(pub class commits |py| {
|
||||
Ok(PyNone)
|
||||
}
|
||||
|
||||
/// Import pull data (serialized in mincode) and flush.
|
||||
/// Import pull data(inside pycell) and flush.
|
||||
/// Returns (commit_count, segment_count) on success.
|
||||
def importpulldata(&self, data: PyBytes) -> PyResult<(u64, usize)> {
|
||||
let data: CloneData<Vertex> = mincode::deserialize(data.data(py)).map_pyerr(py)?;
|
||||
def importpulldata(&self, data: pycell) -> PyResult<(u64, usize)> {
|
||||
let data: Box<CloneData<Vertex>> = data.take(py).ok_or(format_err!("Data is not CloneData")).map_pyerr(py)?;
|
||||
let commits = data.flat_segments.vertex_count();
|
||||
let segments = data.flat_segments.segment_count();
|
||||
let mut inner = self.inner(py).borrow_mut();
|
||||
block_on(inner.import_pull_data(data)).map_pyerr(py)?;
|
||||
block_on(inner.import_pull_data(*data)).map_pyerr(py)?;
|
||||
Ok((commits, segments))
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ use cpython::*;
|
||||
use cpython_async::PyFuture;
|
||||
use cpython_async::TStream;
|
||||
use cpython_ext::convert::Serde;
|
||||
use cpython_ext::pycell;
|
||||
use cpython_ext::{ExtractInner, ExtractInnerRef, PyPathBuf, ResultPyErrExt};
|
||||
use edenapi::{Builder, EdenApi};
|
||||
use edenapi_types::CommitGraphEntry;
|
||||
@ -230,10 +231,9 @@ py_class!(pub class client |py| {
|
||||
self.inner(py).clone().clone_data_py(py, repo)
|
||||
}
|
||||
|
||||
/// pullfastforwardmaster(repo: str, old_master: Bytes, new_master: Bytes) -> bytes
|
||||
/// mincode-serialized CloneData.
|
||||
/// pullfastforwardmaster(repo: str, old_master: Bytes, new_master: Bytes) -> pycell
|
||||
def pullfastforwardmaster(&self, repo: String, old_master: PyBytes, new_master: PyBytes)
|
||||
-> PyResult<PyBytes>
|
||||
-> PyResult<pycell>
|
||||
{
|
||||
self.inner(py).clone().pull_fast_forward_master_py(py, repo, old_master, new_master)
|
||||
}
|
||||
|
@ -15,8 +15,9 @@ use async_runtime::block_unless_interrupted;
|
||||
use cpython_async::PyFuture;
|
||||
use cpython_async::TStream;
|
||||
use cpython_ext::convert::Serde;
|
||||
use cpython_ext::pycell;
|
||||
use cpython_ext::{PyPathBuf, ResultPyErrExt};
|
||||
use dag_types::Location;
|
||||
use dag_types::{Location, VertexName};
|
||||
use edenapi::{EdenApi, EdenApiBlocking, EdenApiError, Fetch, Stats};
|
||||
use edenapi_types::CommitGraphEntry;
|
||||
use edenapi_types::CommitKnownResponse;
|
||||
@ -402,10 +403,10 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
repo: String,
|
||||
old_master: PyBytes,
|
||||
new_master: PyBytes,
|
||||
) -> PyResult<PyBytes> {
|
||||
) -> PyResult<pycell> {
|
||||
let old_master = to_hgid(py, &old_master);
|
||||
let new_master = to_hgid(py, &new_master);
|
||||
let bytes = {
|
||||
let data = {
|
||||
py.allow_threads(|| {
|
||||
block_unless_interrupted(async move {
|
||||
match self
|
||||
@ -413,15 +414,16 @@ pub trait EdenApiPyExt: EdenApi {
|
||||
.await
|
||||
{
|
||||
Err(e) => Err(e),
|
||||
Ok(data) => Ok(mincode::serialize(&data)),
|
||||
Ok(data) => Ok(data.convert_vertex(|hgid| {
|
||||
VertexName(hgid.into_byte_array().to_vec().into())
|
||||
})),
|
||||
}
|
||||
})
|
||||
})
|
||||
.map_pyerr(py)?
|
||||
.map_pyerr(py)?
|
||||
.map_pyerr(py)?
|
||||
};
|
||||
Ok(PyBytes::new(py, &bytes))
|
||||
pycell::new(py, data)
|
||||
}
|
||||
|
||||
fn lookup_file_contents(
|
||||
|
Loading…
Reference in New Issue
Block a user