Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/node.rs Mon Mar 08 19:07:29 2021 +0100 +++ b/rust/hg-core/src/revlog/node.rs Wed Mar 03 16:40:03 2021 +0100 @@ -31,6 +31,9 @@ /// see also `NODES_BYTES_LENGTH` about it being private. const NODE_NYBBLES_LENGTH: usize = 2 * NODE_BYTES_LENGTH; +/// Default for UI presentation +const SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH: u8 = 12; + /// Private alias for readability and to ease future change type NodeData = [u8; NODE_BYTES_LENGTH]; @@ -164,6 +167,13 @@ pub fn as_bytes(&self) -> &[u8] { &self.data } + + pub fn short(&self) -> NodePrefix { + NodePrefix { + nybbles_len: SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH, + data: self.data, + } + } } /// The beginning of a binary revision SHA.