##// END OF EJS Templates
rust-files: also return filenode and flags when listing a revision's files...
Raphaël Gomès -
r52931:b7d99348 default
parent child Browse files
Show More
@@ -5,6 +5,8 b''
5 5 // This software may be used and distributed according to the terms of the
6 6 // GNU General Public License version 2 or any later version.
7 7
8 use std::num::NonZeroU8;
9
8 10 use crate::errors::HgError;
9 11 use crate::matchers::Matcher;
10 12 use crate::repo::Repo;
@@ -12,6 +14,7 b' use crate::revlog::manifest::Manifest;'
12 14 use crate::revlog::RevlogError;
13 15 use crate::utils::filter_map_results;
14 16 use crate::utils::hg_path::HgPath;
17 use crate::Node;
15 18
16 19 /// List files under Mercurial control at a given revision.
17 20 pub fn list_rev_tracked_files(
@@ -31,12 +34,18 b' pub struct FilesForRev {'
31 34 narrow_matcher: Box<dyn Matcher>,
32 35 }
33 36
37 /// Like [`crate::revlog::manifest::ManifestEntry`], but with the `Node`
38 /// already checked.
39 pub type ExpandedManifestEntry<'a> = (&'a HgPath, Node, Option<NonZeroU8>);
40
34 41 impl FilesForRev {
35 pub fn iter(&self) -> impl Iterator<Item = Result<&HgPath, HgError>> {
42 pub fn iter(
43 &self,
44 ) -> impl Iterator<Item = Result<ExpandedManifestEntry, HgError>> {
36 45 filter_map_results(self.manifest.iter(), |entry| {
37 46 let path = entry.path;
38 47 Ok(if self.narrow_matcher.matches(path) {
39 Some(path)
48 Some((path, entry.node_id()?, entry.flags))
40 49 } else {
41 50 None
42 51 })
@@ -90,7 +90,15 b' pub fn run(invocation: &crate::CliInvoca'
90 90 if let Some(rev) = rev {
91 91 let files = list_rev_tracked_files(repo, rev, matcher)
92 92 .map_err(|e| (e, rev.as_ref()))?;
93 display_files(invocation.ui, repo, relative_paths, files.iter())
93 display_files(
94 invocation.ui,
95 repo,
96 relative_paths,
97 files.iter().map::<Result<_, CommandError>, _>(|f| {
98 let (f, _, _) = f?;
99 Ok(f)
100 }),
101 )
94 102 } else {
95 103 // The dirstate always reflects the sparse narrowspec.
96 104 let dirstate = repo.dirstate_map()?;
General Comments 0
You need to be logged in to leave comments. Login now