changeset 48236:f8dc78716ad2

rhg: fix `hg cat` interaction with null revision Differential Revision: https://phab.mercurial-scm.org/D11664
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 14 Oct 2021 19:02:08 +0100
parents 5c567aca080d
children 027ebad952ac
files rust/hg-core/src/revlog/revlog.rs tests/test-rhg.t
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/revlog.rs	Fri Oct 15 01:27:39 2021 +0200
+++ b/rust/hg-core/src/revlog/revlog.rs	Thu Oct 14 19:02:08 2021 +0100
@@ -133,6 +133,9 @@
     /// Returns the node ID for the given revision number, if it exists in this
     /// revlog
     pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> {
+        if rev == NULL_REVISION {
+            return Some(&NULL_NODE);
+        }
         Some(self.index.get_entry(rev)?.hash())
     }
 
--- a/tests/test-rhg.t	Fri Oct 15 01:27:39 2021 +0200
+++ b/tests/test-rhg.t	Thu Oct 14 19:02:08 2021 +0100
@@ -129,8 +129,8 @@
   $ $NO_FALLBACK rhg cat -r d file-2
   2
   $ $NO_FALLBACK rhg cat -r 0000 file-2
-  abort: invalid revision identifier: 0000
-  [255]
+  file-2: no such file in rev 000000000000
+  [1]
 
 Cat files
   $ cd $TESTTMP