##// END OF EJS Templates
perf-unbundle: do a quick and dirty fix to make it run on more commit...
perf-unbundle: do a quick and dirty fix to make it run on more commit Without this change, the perf commands fails within the f67741e8264b::18415fc918a1 range (boundary excluded). Check inline comment for details. With this fix, the command is able to run on this range, with a slightly different behavior (as no revset is "uninlined"). However this is still much better than not being able to run anything in this range. Especially because that range do see some performance regression for unbundle.

File last commit:

r50027:3f5e207f default
r50457:27bff608 stable
Show More
list_tracked_files.rs
82 lines | 2.5 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
rhg: Remove some intermediate Vecs in `rhg files`...
r48164 use crate::dirstate::parsers::parse_dirstate_entries;
Simon Sapin
dirstate-v2: Introduce a docket file...
r48474 use crate::dirstate_tree::on_disk::{for_each_tracked_path, read_docket};
Simon Sapin
rust: use HgError in RevlogError and Vfs...
r47172 use crate::errors::HgError;
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;
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107 use crate::revlog::revlog::RevlogError;
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 use crate::utils::hg_path::HgPath;
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 use crate::DirstateError;
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 use rayon::prelude::*;
/// List files under Mercurial control in the working directory
/// by reading the dirstate
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 pub struct Dirstate {
Antoine Cezar
hg-core: simplify `list_tracked_files` operation...
r46106 /// The `dirstate` content.
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 content: Vec<u8>,
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 v2_metadata: Option<Vec<u8>>,
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 }
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 impl Dirstate {
Simon Sapin
rust: Remove DirstateParseError and ListDirstateTrackedFilesError...
r47169 pub fn new(repo: &Repo) -> Result<Self, HgError> {
Simon Sapin
dirstate-v2: Introduce a docket file...
r48474 let mut content = repo.hg_vfs().read("dirstate")?;
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 let v2_metadata = if repo.has_dirstate_v2() {
Simon Sapin
dirstate-v2: Introduce a docket file...
r48474 let docket = read_docket(&content)?;
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 let meta = docket.tree_metadata().to_vec();
Simon Sapin
dirstate-v2: Introduce a docket file...
r48474 content = repo.hg_vfs().read(docket.data_filename())?;
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 Some(meta)
} else {
None
};
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 Ok(Self {
Simon Sapin
dirstate-v2: Introduce a docket file...
r48474 content,
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 v2_metadata,
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 })
Antoine Cezar
hg-core: simplify `list_tracked_files` operation...
r46106 }
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 pub fn tracked_files(&self) -> Result<Vec<&HgPath>, DirstateError> {
Simon Sapin
rhg: Remove some intermediate Vecs in `rhg files`...
r48164 let mut files = Vec::new();
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 if !self.content.is_empty() {
Simon Sapin
dirstate-v2: Move fixed-size tree metadata into the docket file...
r48482 if let Some(meta) = &self.v2_metadata {
for_each_tracked_path(&self.content, meta, |path| {
files.push(path)
})?
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 } else {
let _parents = parse_dirstate_entries(
&self.content,
|path, entry, _copy_source| {
Raphaël Gomès
rust: use `entry.tracked()` directly...
r50027 if entry.tracked() {
Simon Sapin
rhg: Add support for dirstate-v2...
r48165 files.push(path)
}
Ok(())
},
)?;
}
}
Antoine Cezar
hg-core: define a `ListTrackedFiles` `Operation`...
r45918 files.par_sort_unstable();
Ok(files)
}
}
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,
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)?;
Simon Sapin
rhg: Reuse manifest when checking status of multiple ambiguous files...
r48778 Ok(FilesForRev(repo.manifest_for_rev(rev)?))
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107 }
Simon Sapin
rust: Rename Manifest to Manifestlog, ManifestEntry to Manifest...
r48771 pub struct FilesForRev(Manifest);
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>> {
Simon Sapin
rhg: Also parse flags in the manifest parser...
r49166 self.0.iter().map(|entry| Ok(entry?.path))
Antoine Cezar
hg-core: add a `ListRevTrackedFiles` operation...
r46107 }
}