Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/parsers.rs @ 46595:98a455a62699
rust: Make `DirstateParents`?s fields typed `Node`s
Instead of plain byte arrays.
Differential Revision: https://phab.mercurial-scm.org/D10006
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 17 Feb 2021 12:24:53 +0100 |
parents | 776b97179c06 |
children | 5d62243c7732 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/parsers.rs Wed Feb 17 12:06:56 2021 +0100 +++ b/rust/hg-cpython/src/parsers.rs Wed Feb 17 12:24:53 2021 +0100 @@ -53,10 +53,7 @@ PyBytes::new(py, copy_path.as_bytes()), )?; } - Ok( - (PyBytes::new(py, &parents.p1), PyBytes::new(py, &parents.p2)) - .to_py_object(py), - ) + Ok(dirstate_parents_to_pytuple(py, parents)) } Err(e) => Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())), } @@ -155,3 +152,12 @@ Ok(m) } + +pub(crate) fn dirstate_parents_to_pytuple( + py: Python, + parents: &DirstateParents, +) -> PyTuple { + let p1 = PyBytes::new(py, parents.p1.as_bytes()); + let p2 = PyBytes::new(py, parents.p2.as_bytes()); + (p1, p2).to_py_object(py) +}