changeset 47322:1760de72a992

rhg: A missing .hg/dirstate file is not an error Instead treat it as like an empty file Differential Revision: https://phab.mercurial-scm.org/D10766
author Simon Sapin <simon.sapin@octobus.net>
date Sat, 22 May 2021 17:35:54 +0200
parents 62225f9da938
children f612db768c7a
files rust/rhg/src/commands/status.rs
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs	Sat May 22 17:32:09 2021 +0200
+++ b/rust/rhg/src/commands/status.rs	Sat May 22 17:35:54 2021 +0200
@@ -9,6 +9,7 @@
 use crate::ui::Ui;
 use clap::{Arg, SubCommand};
 use hg;
+use hg::errors::HgResultExt;
 use hg::errors::IoResultExt;
 use hg::matchers::AlwaysMatcher;
 use hg::operations::cat;
@@ -164,8 +165,13 @@
 
     let repo = invocation.repo?;
     let mut dmap = DirstateMap::new();
-    let dirstate_data = repo.hg_vfs().mmap_open("dirstate")?;
-    let parents = dmap.read(&dirstate_data)?;
+    let dirstate_data =
+        repo.hg_vfs().mmap_open("dirstate").io_not_found_as_none()?;
+    let dirstate_data = match &dirstate_data {
+        Some(mmap) => &**mmap,
+        None => b"",
+    };
+    let parents = dmap.read(dirstate_data)?;
     let options = StatusOptions {
         // TODO should be provided by the dirstate parsing and
         // hence be stored on dmap. Using a value that assumes we aren't