changeset 46429:e61c2dc6e1c2

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
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 25 Jan 2021 12:31:40 +0100
parents 5893706af3de
children b84c3d43ff2e
files rust/hg-core/src/revlog/node.rs
diffstat 1 files changed, 1 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;