--- 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.