[Updated] D11409: rhg: Align with Python on some revset parsing corner cases

SimonSapin phabricator at mercurial-scm.org
Tue Sep 14 08:20:50 UTC 2021


Closed by commit rHG8c29af0f6d6e: rhg: Align with Python on some revset parsing corner cases (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/D11409?vs=30227&id=30237

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

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

AFFECTED FILES
  rust/hg-core/src/revlog/revlog.rs
  rust/hg-core/src/revset.rs
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -126,6 +126,9 @@
   [255]
   $ $NO_FALLBACK rhg cat -r d file-2
   2
+  $ $NO_FALLBACK rhg cat -r 0000 file-2
+  abort: invalid revision identifier: 0000
+  [255]
 
 Cat files
   $ cd $TESTTMP
diff --git a/rust/hg-core/src/revset.rs b/rust/hg-core/src/revset.rs
--- a/rust/hg-core/src/revset.rs
+++ b/rust/hg-core/src/revset.rs
@@ -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);
         }
     }
diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -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)?



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


More information about the Mercurial-patches mailing list