mirror of
https://github.com/facebook/sapling.git
synced 2024-12-28 07:33:10 +03:00
py3: fix treedirstate unicode handling
Summary: There was a spot where we returned bytes for a filepath. Fix this to make dirstate tests pass more. Reviewed By: quark-zju Differential Revision: D19786274 fbshipit-source-id: 7465cae8bb2e3be7758abc6279ed3f5f59581732
This commit is contained in:
parent
4f8c30b04e
commit
fdbaaeeff9
@ -256,7 +256,7 @@ py_class!(class treedirstatemap |py| {
|
|||||||
// Get the next dirstate object after the provided filename. If the filename is None,
|
// Get the next dirstate object after the provided filename. If the filename is None,
|
||||||
// returns the first file in the tree. If the provided filename is the last file, returns
|
// returns the first file in the tree. If the provided filename is the last file, returns
|
||||||
// None.
|
// None.
|
||||||
def getnext(&self, filename: Option<PyPathBuf>, removed: bool) -> PyResult<Option<(PyBytes, (PyString, u32, i32, i32))>> {
|
def getnext(&self, filename: Option<PyPathBuf>, removed: bool) -> PyResult<Option<(PyPathBuf, (PyString, u32, i32, i32))>> {
|
||||||
let mut dirstate = self.dirstate(py).borrow_mut();
|
let mut dirstate = self.dirstate(py).borrow_mut();
|
||||||
let next = if removed {
|
let next = if removed {
|
||||||
match filename {
|
match filename {
|
||||||
@ -284,7 +284,16 @@ py_class!(class treedirstatemap |py| {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(next.map(|(f, s)| (PyBytes::new(py, &f), (PyString::new(py, unsafe {std::str::from_utf8_unchecked(&[s.state; 1])}), s.mode, s.size, s.mtime))))
|
|
||||||
|
Ok(match next {
|
||||||
|
Some((f, s)) => {
|
||||||
|
Some((
|
||||||
|
PyPathBuf::from_utf8_bytes(f.to_vec()).map_pyerr(py)?,
|
||||||
|
(PyString::new(py, unsafe {std::str::from_utf8_unchecked(&[s.state; 1])}), s.mode, s.size, s.mtime)
|
||||||
|
))
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
def addfile(
|
def addfile(
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#require py2
|
|
||||||
#chg-compatible
|
#chg-compatible
|
||||||
|
|
||||||
$ disable treemanifest
|
$ disable treemanifest
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#require py2
|
|
||||||
#chg-compatible
|
#chg-compatible
|
||||||
|
|
||||||
This test tries to exercise the ssh functionality with a dummy script
|
This test tries to exercise the ssh functionality with a dummy script
|
||||||
|
Loading…
Reference in New Issue
Block a user