diff rust/hg-core/src/revlog/revlog.rs @ 47962:8c29af0f6d6e

rhg: Align with Python on some revset parsing corner cases In particular: * A string of ASCII digits can be either an integer on a hex prefix * The NULL node ID should convert to the NULL revision number Differential Revision: https://phab.mercurial-scm.org/D11409
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 13 Sep 2021 17:23:42 +0200
parents fad504cfc94b
children 001d747c2baf
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/revlog.rs	Mon Sep 13 15:42:39 2021 +0200
+++ b/rust/hg-core/src/revlog/revlog.rs	Mon Sep 13 17:23:42 2021 +0200
@@ -18,6 +18,7 @@
 use crate::errors::HgError;
 use crate::repo::Repo;
 use crate::revlog::Revision;
+use crate::NULL_REVISION;
 
 #[derive(derive_more::From)]
 pub enum RevlogError {
@@ -124,6 +125,10 @@
         &self,
         node: NodePrefix,
     ) -> Result<Revision, RevlogError> {
+        if node.is_prefix_of(&NULL_NODE) {
+            return Ok(NULL_REVISION);
+        }
+
         if let Some(nodemap) = &self.nodemap {
             return nodemap
                 .find_bin(&self.index, node)?