[Commented On] D10549: dirstate-tree: Handle I/O errors in status
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Thu May 6 16:04:08 UTC 2021
baymax added a comment.
baymax updated this revision to Diff 27625.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10549?vs=27324&id=27625
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10549/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10549
AFFECTED FILES
rust/hg-core/src/dirstate_tree/status.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/dirstate_tree/status.rs b/rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs
+++ b/rust/hg-core/src/dirstate_tree/status.rs
@@ -6,6 +6,7 @@
use crate::matchers::Matcher;
use crate::utils::files::get_bytes_from_os_string;
use crate::utils::hg_path::HgPath;
+use crate::BadMatch;
use crate::DirstateStatus;
use crate::EntryState;
use crate::HgPathBuf;
@@ -69,17 +70,37 @@
}
impl<'tree, 'a> StatusCommon<'tree, 'a> {
+ fn read_dir(
+ &mut self,
+ hg_path: &HgPath,
+ fs_path: &Path,
+ is_at_repo_root: bool,
+ ) -> Result<Vec<DirEntry>, ()> {
+ DirEntry::read_dir(fs_path, is_at_repo_root).map_err(|error| {
+ let errno = error.raw_os_error().expect("expected real OS error");
+ self.outcome
+ .bad
+ .push((hg_path.to_owned().into(), BadMatch::OsError(errno)))
+ })
+ }
+
fn traverse_fs_directory_and_dirstate(
&mut self,
has_ignored_ancestor: bool,
dirstate_nodes: &'tree mut ChildNodes,
- directory_hg_path: &HgPath,
- fs_path: &Path,
+ directory_hg_path: &'tree HgPath,
+ directory_fs_path: &Path,
is_at_repo_root: bool,
) {
- // TODO: handle I/O errors
- let mut fs_entries =
- DirEntry::read_dir(fs_path, is_at_repo_root).unwrap();
+ let mut fs_entries = if let Ok(entries) = self.read_dir(
+ directory_hg_path,
+ directory_fs_path,
+ is_at_repo_root,
+ ) {
+ entries
+ } else {
+ return;
+ };
// `merge_join_by` requires both its input iterators to be sorted:
@@ -295,16 +316,18 @@
};
if traverse_children {
let is_at_repo_root = false;
- // TODO: handle I/O errors
- let children_fs_entries =
- DirEntry::read_dir(&fs_entry.full_path, is_at_repo_root)
- .unwrap();
- for child_fs_entry in children_fs_entries {
- self.traverse_fs_only(
- is_ignored,
- &hg_path,
- &child_fs_entry,
- )
+ if let Ok(children_fs_entries) = self.read_dir(
+ &hg_path,
+ &fs_entry.full_path,
+ is_at_repo_root,
+ ) {
+ for child_fs_entry in children_fs_entries {
+ self.traverse_fs_only(
+ is_ignored,
+ &hg_path,
+ &child_fs_entry,
+ )
+ }
}
}
if self.options.collect_traversed_dirs {
To: SimonSapin, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210506/91c79a42/attachment-0002.html>
More information about the Mercurial-patches
mailing list