rhg: fix `hg cat` interaction with null revision
Differential Revision: https://phab.mercurial-scm.org/D11664
--- 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