mirror of
https://github.com/facebook/sapling.git
synced 2024-12-29 16:12:23 +03:00
bindings: add repair to structures
Summary: Expose the repair API to the Python world. Reviewed By: xavierd Differential Revision: D18737913 fbshipit-source-id: c31085727589b6938c2fafb28897925aea617bc4
This commit is contained in:
parent
02b4902319
commit
d754747d01
@ -7,7 +7,7 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use ::metalog::{CommitOptions, Id20, MetaLog};
|
||||
use ::metalog::{CommitOptions, Id20, MetaLog, Repair};
|
||||
use cpython::*;
|
||||
use cpython_ext::Bytes;
|
||||
use cpython_failure::ResultPyErrExt;
|
||||
@ -106,4 +106,9 @@ py_class!(class metalog |py| {
|
||||
self.remove(py, &key)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &str) -> PyResult<PyUnicode> {
|
||||
MetaLog::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ use cpython::*;
|
||||
use cpython_failure::ResultPyErrExt;
|
||||
use thiserror::Error;
|
||||
|
||||
use ::mutationstore::{MutationEntry, MutationEntryOrigin, MutationStore};
|
||||
use ::mutationstore::{MutationEntry, MutationEntryOrigin, MutationStore, Repair};
|
||||
use encoding::local_bytes_to_path;
|
||||
use types::node::Node;
|
||||
use vlqencoding::{VLQDecode, VLQEncode};
|
||||
@ -251,4 +251,9 @@ py_class!(class mutationstore |py| {
|
||||
}
|
||||
Ok(pyssets)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &str) -> PyResult<PyUnicode> {
|
||||
MutationStore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ use std::cell::RefCell;
|
||||
|
||||
use cpython::*;
|
||||
|
||||
use ::nodemap::{NodeMap, NodeSet};
|
||||
use ::nodemap::{NodeMap, NodeSet, Repair};
|
||||
use cpython_ext::Bytes;
|
||||
use cpython_failure::ResultPyErrExt;
|
||||
use encoding::local_bytes_to_path;
|
||||
@ -86,6 +86,11 @@ py_class!(class nodemap |py| {
|
||||
.map_err(|e| PyErr::new::<exc::RuntimeError, _>(py, format!("{}", e)))?;
|
||||
Ok(keys)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &str) -> PyResult<PyUnicode> {
|
||||
NodeMap::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
});
|
||||
|
||||
py_class!(class nodeset |py| {
|
||||
@ -123,4 +128,9 @@ py_class!(class nodeset |py| {
|
||||
.map_pyerr::<exc::IOError>(py)?;
|
||||
Ok(nodes)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &str) -> PyResult<PyUnicode> {
|
||||
NodeSet::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ use anyhow::{format_err, Error};
|
||||
use cpython::*;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use cpython_ext::{Bytes, PyErr};
|
||||
use cpython_ext::PyErr;
|
||||
use cpython_failure::ResultPyErrExt;
|
||||
use pyconfigparser::config;
|
||||
use revisionstore::{
|
||||
@ -410,9 +410,9 @@ py_class!(class indexedlogdatastore |py| {
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &PyBytes) -> PyResult<Bytes> {
|
||||
def repair(path: &PyBytes) -> PyResult<PyUnicode> {
|
||||
let path = encoding::local_bytes_to_path(path.data(py)).map_pyerr::<exc::TypeError>(py)?;
|
||||
IndexedLogDataStore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| Bytes::from(s))
|
||||
IndexedLogDataStore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
|
||||
def getdelta(&self, name: &PyBytes, node: &PyBytes) -> PyResult<PyObject> {
|
||||
@ -463,9 +463,9 @@ py_class!(class indexedloghistorystore |py| {
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &PyBytes) -> PyResult<Bytes> {
|
||||
def repair(path: &PyBytes) -> PyResult<PyUnicode> {
|
||||
let path = encoding::local_bytes_to_path(path.data(py)).map_pyerr::<exc::TypeError>(py)?;
|
||||
IndexedLogHistoryStore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| Bytes::from(s))
|
||||
IndexedLogHistoryStore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
|
||||
def getmissing(&self, keys: &PyObject) -> PyResult<PyList> {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use ::zstore::{Id20, Zstore};
|
||||
use ::zstore::{Id20, Repair, Zstore};
|
||||
use cpython::*;
|
||||
use cpython_ext::Bytes;
|
||||
use cpython_failure::ResultPyErrExt;
|
||||
@ -66,4 +66,9 @@ py_class!(class zstore |py| {
|
||||
def __contains__(&self, id: Bytes) -> PyResult<bool> {
|
||||
self.contains(py, id)
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def repair(path: &str) -> PyResult<PyUnicode> {
|
||||
Zstore::repair(path).map_pyerr::<exc::IOError>(py).map(|s| PyUnicode::new(py, &s))
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user