rhg: fix `hg cat` interaction with null revision
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Thu, 14 Oct 2021 19:02:08 +0100
changeset 48236 f8dc78716ad2
parent 48235 5c567aca080d
child 48237 027ebad952ac
rhg: fix `hg cat` interaction with null revision Differential Revision: https://phab.mercurial-scm.org/D11664
rust/hg-core/src/revlog/revlog.rs
tests/test-rhg.t
--- 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