rust/hg-cpython/src/revlog.rs
branchstable
changeset 49374 455fce57e89e
parent 48269 aa88fb60ecb4
child 49914 58074252db3c
equal deleted inserted replaced
49373:f8ec7b16c98f 49374:455fce57e89e
   105         else {
   105         else {
   106             let node = node.extract::<PyBytes>(py)?;
   106             let node = node.extract::<PyBytes>(py)?;
   107             String::from_utf8_lossy(node.data(py)).to_string()
   107             String::from_utf8_lossy(node.data(py)).to_string()
   108         };
   108         };
   109 
   109 
   110         let prefix = NodePrefix::from_hex(&node_as_string).map_err(|_| PyErr::new::<ValueError, _>(py, "Invalid node or prefix"))?;
   110         let prefix = NodePrefix::from_hex(&node_as_string)
       
   111             .map_err(|_| PyErr::new::<ValueError, _>(
       
   112                 py, format!("Invalid node or prefix '{}'", node_as_string))
       
   113             )?;
   111 
   114 
   112         nt.find_bin(idx, prefix)
   115         nt.find_bin(idx, prefix)
   113             // TODO make an inner API returning the node directly
   116             // TODO make an inner API returning the node directly
   114             .map(|opt| opt.map(
   117             .map(|opt| opt.map(
   115                 |rev| PyBytes::new(py, idx.node(rev).unwrap().as_bytes())))
   118                 |rev| PyBytes::new(py, idx.node(rev).unwrap().as_bytes())))