[Updated] D9862: rust: Exclude empty node prefixes

SimonSapin phabricator at mercurial-scm.org
Sun Jan 31 20:26:47 UTC 2021


Closed by commit rHGe61c2dc6e1c2: rust: Exclude empty node prefixes (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9862?vs=25350&id=25416

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9862/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D9862

AFFECTED FILES
  rust/hg-core/src/revlog/node.rs

CHANGE DETAILS

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 @@
     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;



To: SimonSapin, #hg-reviewers, Alphare, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210131/ecc8ce40/attachment-0002.html>


More information about the Mercurial-patches mailing list