Mercurial > public > mercurial-scm > hg
diff rust/rhg/src/commands/status.rs @ 47374:bd88b6bfd8da
rhg: Add support for dirstate-v2
Differential Revision: https://phab.mercurial-scm.org/D10804
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 25 May 2021 09:20:30 +0200 |
parents | 1760de72a992 |
children | ff97e793ed36 |
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs Wed May 26 11:53:37 2021 +0200 +++ b/rust/rhg/src/commands/status.rs Tue May 25 09:20:30 2021 +0200 @@ -9,6 +9,7 @@ use crate::ui::Ui; use clap::{Arg, SubCommand}; use hg; +use hg::dirstate_tree::dirstate_map::DirstateMap; use hg::errors::HgResultExt; use hg::errors::IoResultExt; use hg::matchers::AlwaysMatcher; @@ -16,7 +17,7 @@ use hg::repo::Repo; use hg::revlog::node::Node; use hg::utils::hg_path::{hg_path_to_os_string, HgPath}; -use hg::{DirstateMap, StatusError}; +use hg::StatusError; use hg::{HgPathCow, StatusOptions}; use log::{info, warn}; use std::convert::TryInto; @@ -164,14 +165,17 @@ }; let repo = invocation.repo?; - let mut dmap = DirstateMap::new(); 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 (mut dmap, parents) = if repo.has_dirstate_v2() { + DirstateMap::new_v2(dirstate_data)? + } else { + DirstateMap::new_v1(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 @@ -187,8 +191,8 @@ collect_traversed_dirs: false, }; let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded - let (mut ds_status, pattern_warnings) = hg::status( - &dmap, + let (mut ds_status, pattern_warnings) = hg::dirstate_tree::status::status( + &mut dmap, &AlwaysMatcher, repo.working_directory_path().to_owned(), vec![ignore_file],