[Updated] [+ ] D11664: rhg: fix `hg cat` interaction with null revision

aalekseyev (Arseniy Alekseyev) phabricator at mercurial-scm.org
Fri Oct 15 13:39:09 UTC 2021


aalekseyev updated this revision to Diff 30838.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11664?vs=30809&id=30838

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/operations/cat.rs
  rust/hg-core/src/revlog/revlog.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
@@ -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
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
@@ -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())
     }
 
diff --git a/rust/hg-core/src/operations/cat.rs b/rust/hg-core/src/operations/cat.rs
--- a/rust/hg-core/src/operations/cat.rs
+++ b/rust/hg-core/src/operations/cat.rs
@@ -104,10 +104,8 @@
         bytes.extend(file_log.data_for_node(file_node)?.data()?);
     }
 
-    let missing: Vec<HgPathBuf> = missing
-        .iter()
-        .map(|file| (*file).to_owned())
-        .collect();
+    let missing: Vec<HgPathBuf> =
+        missing.iter().map(|file| (*file).to_owned()).collect();
     Ok(CatOutput {
         found_any,
         concatenated: bytes,



To: aalekseyev, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211015/869f9a50/attachment-0002.html>


More information about the Mercurial-patches mailing list