##// END OF EJS Templates
undo-files: factor the vfs map in a repository property...
undo-files: factor the vfs map in a repository property We define it in multiple locations and inconsistencies are appearing. So we now have a single definition point.

File last commit:

r50880:e57f76c2 default
r51189:f3488731 stable
Show More
list_tracked_files.rs
45 lines | 1.2 KiB | application/rls-services+xml | RustLexer
/ rust / hg-core / src / operations / list_tracked_files.rs
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 // list_tracked_files.rs
//
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Simon Sapin
rust: use HgError in RevlogError and Vfs...
r47172 use crate::errors::HgError;
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 use crate::matchers::Matcher;
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use crate::repo::Repo;
Simon Sapin
rust: Keep lazily-initialized Changelog and Manifest log on the Repo object...
r48773 use crate::revlog::manifest::Manifest;
Raphaël Gomès
rust-clippy: merge "revlog" module definition and struct implementation...
r50832 use crate::revlog::RevlogError;
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 use crate::utils::filter_map_results;
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 use crate::utils::hg_path::HgPath;
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107
/// List files under Mercurial control at a given revision.
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 pub fn list_rev_tracked_files(
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 repo: &Repo,
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 revset: &str,
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 narrow_matcher: Box<dyn Matcher>,
Simon Sapin
rust: remove three enums that were identical to `RevlogError`...
r47166 ) -> Result<FilesForRev, RevlogError> {
Simon Sapin
rhg: centralize parsing of `--rev` CLI arguments...
r47162 let rev = crate::revset::resolve_single(revset, repo)?;
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 Ok(FilesForRev {
manifest: repo.manifest_for_rev(rev)?,
narrow_matcher,
})
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107 }
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 pub struct FilesForRev {
manifest: Manifest,
narrow_matcher: Box<dyn Matcher>,
}
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 impl FilesForRev {
Simon Sapin
rhg: Propogate manifest parse errors instead of panicking...
r49165 pub fn iter(&self) -> impl Iterator<Item = Result<&HgPath, HgError>> {
Raphaël Gomès
rhg-files: add support for narrow when specifying a revision...
r50880 filter_map_results(self.manifest.iter(), |entry| {
let path = entry.path;
Ok(if self.narrow_matcher.matches(path) {
Some(path)
} else {
None
})
})
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107 }
}