# HG changeset patch # User Simon Sapin # Date 2021-01-25 11:31:40 # Node ID e61c2dc6e1c2fbbbc0a1402adfccbd50c0485f63 # Parent 5893706af3decde7b3a63ec4b4fa188d02cddecb rust: Exclude empty node prefixes We presumably don’t want `--rev ""` to select every single revision, even though the empty string is a prefix of all strings. Differential Revision: https://phab.mercurial-scm.org/D9862 diff --git a/rust/hg-core/src/revlog/node.rs b/rust/hg-core/src/revlog/node.rs --- a/rust/hg-core/src/revlog/node.rs +++ b/rust/hg-core/src/revlog/node.rs @@ -160,7 +160,7 @@ impl NodePrefix { pub fn from_hex(hex: impl AsRef<[u8]>) -> Result { let hex = hex.as_ref(); let len = hex.len(); - if len > NODE_NYBBLES_LENGTH { + if len > NODE_NYBBLES_LENGTH || len == 0 { return Err(FromHexError); } @@ -201,10 +201,6 @@ impl<'a> NodePrefixRef<'a> { } } - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - pub fn is_prefix_of(&self, node: &Node) -> bool { if self.is_odd { let buf = self.buf;