Mercurial > hg
comparison rust/hg-core/src/revlog/node.rs @ 46744:b1f2c2b336ec
rhg: `cat` command: print error messages for missing files
And exit with an error code if no file was matched.
This matches the behavior of Python-based hg.
Differential Revision: https://phab.mercurial-scm.org/D10142
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 03 Mar 2021 16:40:03 +0100 |
parents | 98a455a62699 |
children | 2097f63575a5 |
comparison
equal
deleted
inserted
replaced
46743:84a3deca963a | 46744:b1f2c2b336ec |
---|---|
28 | 28 |
29 /// The length in bytes of a `Node` | 29 /// The length in bytes of a `Node` |
30 /// | 30 /// |
31 /// see also `NODES_BYTES_LENGTH` about it being private. | 31 /// see also `NODES_BYTES_LENGTH` about it being private. |
32 const NODE_NYBBLES_LENGTH: usize = 2 * NODE_BYTES_LENGTH; | 32 const NODE_NYBBLES_LENGTH: usize = 2 * NODE_BYTES_LENGTH; |
33 | |
34 /// Default for UI presentation | |
35 const SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH: u8 = 12; | |
33 | 36 |
34 /// Private alias for readability and to ease future change | 37 /// Private alias for readability and to ease future change |
35 type NodeData = [u8; NODE_BYTES_LENGTH]; | 38 type NodeData = [u8; NODE_BYTES_LENGTH]; |
36 | 39 |
37 /// Binary revision SHA | 40 /// Binary revision SHA |
161 /// | 164 /// |
162 /// This is needed by FFI layers, for instance to return expected | 165 /// This is needed by FFI layers, for instance to return expected |
163 /// binary values to Python. | 166 /// binary values to Python. |
164 pub fn as_bytes(&self) -> &[u8] { | 167 pub fn as_bytes(&self) -> &[u8] { |
165 &self.data | 168 &self.data |
169 } | |
170 | |
171 pub fn short(&self) -> NodePrefix { | |
172 NodePrefix { | |
173 nybbles_len: SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH, | |
174 data: self.data, | |
175 } | |
166 } | 176 } |
167 } | 177 } |
168 | 178 |
169 /// The beginning of a binary revision SHA. | 179 /// The beginning of a binary revision SHA. |
170 /// | 180 /// |