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
--- a/rust/hg-core/src/revlog/node.rs Mon Jan 25 12:28:39 2021 +0100
+++ b/rust/hg-core/src/revlog/node.rs Mon Jan 25 12:31:40 2021 +0100
@@ -160,7 +160,7 @@
pub fn from_hex(hex: impl AsRef<[u8]>) -> Result<Self, FromHexError> {
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 @@
}
}
- 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;