Mercurial > public > mercurial-scm > hg-stable
diff rust/rhg/src/commands/files.rs @ 50036:95ffa065204e
rhg-files: reuse centralized dirstate logic
The `files` logic predates the centralized dirstate logic. It was duplicated,
an didn't receive bugfixes along the way.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 11 Jan 2023 16:29:29 +0100 |
parents | e43f91244de2 |
children | 795b5b01cbd2 |
line wrap: on
line diff
--- a/rust/rhg/src/commands/files.rs Wed Jan 11 17:27:19 2023 +0100 +++ b/rust/rhg/src/commands/files.rs Wed Jan 11 16:29:29 2023 +0100 @@ -4,9 +4,10 @@ use clap::Arg; use hg::errors::HgError; use hg::operations::list_rev_tracked_files; -use hg::operations::Dirstate; use hg::repo::Repo; +use hg::utils::filter_map_results; use hg::utils::hg_path::HgPath; +use rayon::prelude::*; pub const HELP_TEXT: &str = " List tracked files. @@ -70,8 +71,16 @@ "rhg files is not supported in narrow clones", )); } - let dirstate = Dirstate::new(repo)?; - let files = dirstate.tracked_files()?; + let dirstate = repo.dirstate_map()?; + let files_res: Result<Vec<_>, _> = + filter_map_results(dirstate.iter(), |(path, entry)| { + Ok(if entry.tracked() { Some(path) } else { None }) + }) + .collect(); + + let mut files = files_res?; + files.par_sort_unstable(); + display_files(invocation.ui, repo, files.into_iter().map(Ok)) } }