Mercurial > hg
changeset 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 | 4d2a5ca060e3 |
children | 001d747c2baf |
files | rust/hg-core/src/revlog/revlog.rs rust/hg-core/src/revset.rs tests/test-rhg.t |
diffstat | 3 files changed, 15 insertions(+), 1 deletions(-) [+] |
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)?
--- a/rust/hg-core/src/revset.rs Mon Sep 13 15:42:39 2021 +0200 +++ b/rust/hg-core/src/revset.rs Mon Sep 13 17:23:42 2021 +0200 @@ -45,8 +45,14 @@ input: &str, revlog: &Revlog, ) -> Result<Revision, RevlogError> { + // The Python equivalent of this is part of `revsymbol` in + // `mercurial/scmutil.py` + if let Ok(integer) = input.parse::<i32>() { - if integer >= 0 && revlog.has_rev(integer) { + if integer.to_string() == input + && integer >= 0 + && revlog.has_rev(integer) + { return Ok(integer); } }