##// 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 // This software may be used and distributed according to the terms of the
5 // This software may be used and distributed according to the terms of the
6 // GNU General Public License version 2 or any later version.
6 // GNU General Public License version 2 or any later version.
7
7
8 use std::num::NonZeroU8;
9
8 use crate::errors::HgError;
10 use crate::errors::HgError;
9 use crate::matchers::Matcher;
11 use crate::matchers::Matcher;
10 use crate::repo::Repo;
12 use crate::repo::Repo;
@@ -12,6 +14,7 b' use crate::revlog::manifest::Manifest;'
12 use crate::revlog::RevlogError;
14 use crate::revlog::RevlogError;
13 use crate::utils::filter_map_results;
15 use crate::utils::filter_map_results;
14 use crate::utils::hg_path::HgPath;
16 use crate::utils::hg_path::HgPath;
17 use crate::Node;
15
18
16 /// List files under Mercurial control at a given revision.
19 /// List files under Mercurial control at a given revision.
17 pub fn list_rev_tracked_files(
20 pub fn list_rev_tracked_files(
@@ -31,12 +34,18 b' pub struct FilesForRev {'
31 narrow_matcher: Box<dyn Matcher>,
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 impl FilesForRev {
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 filter_map_results(self.manifest.iter(), |entry| {
45 filter_map_results(self.manifest.iter(), |entry| {
37 let path = entry.path;
46 let path = entry.path;
38 Ok(if self.narrow_matcher.matches(path) {
47 Ok(if self.narrow_matcher.matches(path) {
39 Some(path)
48 Some((path, entry.node_id()?, entry.flags))
40 } else {
49 } else {
41 None
50 None
42 })
51 })
@@ -90,7 +90,15 b' pub fn run(invocation: &crate::CliInvoca'
90 if let Some(rev) = rev {
90 if let Some(rev) = rev {
91 let files = list_rev_tracked_files(repo, rev, matcher)
91 let files = list_rev_tracked_files(repo, rev, matcher)
92 .map_err(|e| (e, rev.as_ref()))?;
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 } else {
102 } else {
95 // The dirstate always reflects the sparse narrowspec.
103 // The dirstate always reflects the sparse narrowspec.
96 let dirstate = repo.dirstate_map()?;
104 let dirstate = repo.dirstate_map()?;
General Comments 0
You need to be logged in to leave comments. Login now