changeset 52040:7c105b953ca4

rust-files: separate the listing of files from a revset and a revision We won't need to parse a revset all the time, and an upcoming patch will make use of this new util.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 30 Sep 2024 19:15:19 +0200
parents b8b3984deae3
children 3ae7c43ad8aa
files rust/hg-core/src/operations/list_tracked_files.rs rust/hg-core/src/operations/mod.rs rust/rhg/src/commands/files.rs
diffstat 3 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/operations/list_tracked_files.rs	Mon Sep 30 19:12:42 2024 +0200
+++ b/rust/hg-core/src/operations/list_tracked_files.rs	Mon Sep 30 19:15:19 2024 +0200
@@ -14,10 +14,10 @@
 use crate::revlog::RevlogError;
 use crate::utils::filter_map_results;
 use crate::utils::hg_path::HgPath;
-use crate::Node;
+use crate::{Node, UncheckedRevision};
 
-/// List files under Mercurial control at a given revision.
-pub fn list_rev_tracked_files(
+/// List files under Mercurial control at a given revset.
+pub fn list_revset_tracked_files(
     repo: &Repo,
     revset: &str,
     narrow_matcher: Box<dyn Matcher + Sync>,
@@ -29,6 +29,18 @@
     })
 }
 
+/// List files under Mercurial control at a given revision.
+pub fn list_rev_tracked_files(
+    repo: &Repo,
+    rev: UncheckedRevision,
+    narrow_matcher: Box<dyn Matcher + Sync>,
+) -> Result<FilesForRev, RevlogError> {
+    Ok(FilesForRev {
+        manifest: repo.manifest_for_rev(rev)?,
+        narrow_matcher,
+    })
+}
+
 pub struct FilesForRev {
     manifest: Manifest,
     narrow_matcher: Box<dyn Matcher + Sync>,
--- a/rust/hg-core/src/operations/mod.rs	Mon Sep 30 19:12:42 2024 +0200
+++ b/rust/hg-core/src/operations/mod.rs	Mon Sep 30 19:15:19 2024 +0200
@@ -8,5 +8,8 @@
 mod status_rev_rev;
 pub use cat::{cat, CatOutput};
 pub use debugdata::debug_data;
-pub use list_tracked_files::{list_rev_tracked_files, FilesForRev};
+pub use list_tracked_files::{
+    list_rev_tracked_files, list_revset_tracked_files, ExpandedManifestEntry,
+    FilesForRev,
+};
 pub use status_rev_rev::{status_rev_rev_no_copies, DiffStatus, StatusRevRev};
--- a/rust/rhg/src/commands/files.rs	Mon Sep 30 19:12:42 2024 +0200
+++ b/rust/rhg/src/commands/files.rs	Mon Sep 30 19:15:19 2024 +0200
@@ -7,7 +7,7 @@
 use hg::filepatterns::parse_pattern_args;
 use hg::matchers::IntersectionMatcher;
 use hg::narrow;
-use hg::operations::list_rev_tracked_files;
+use hg::operations::list_revset_tracked_files;
 use hg::repo::Repo;
 use hg::utils::files::get_bytes_from_os_str;
 use hg::utils::filter_map_results;
@@ -88,7 +88,7 @@
     };
 
     if let Some(rev) = rev {
-        let files = list_rev_tracked_files(repo, rev, matcher)
+        let files = list_revset_tracked_files(repo, rev, matcher)
             .map_err(|e| (e, rev.as_ref()))?;
         display_files(
             invocation.ui,