SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Instead of calling `parse_dirstate` which then calls `parse_dirstate_entries`,
  call the latter directly in order to skip some intermediate steps.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10803

AFFECTED FILES
  rust/hg-core/src/operations/list_tracked_files.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/operations/list_tracked_files.rs 
b/rust/hg-core/src/operations/list_tracked_files.rs
--- a/rust/hg-core/src/operations/list_tracked_files.rs
+++ b/rust/hg-core/src/operations/list_tracked_files.rs
@@ -5,7 +5,7 @@
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
-use crate::dirstate::parsers::parse_dirstate;
+use crate::dirstate::parsers::parse_dirstate_entries;
 use crate::errors::HgError;
 use crate::repo::Repo;
 use crate::revlog::changelog::Changelog;
@@ -13,7 +13,6 @@
 use crate::revlog::node::Node;
 use crate::revlog::revlog::RevlogError;
 use crate::utils::hg_path::HgPath;
-use crate::EntryState;
 use rayon::prelude::*;
 
 /// List files under Mercurial control in the working directory
@@ -30,14 +29,16 @@
     }
 
     pub fn tracked_files(&self) -> Result<Vec<&HgPath>, HgError> {
-        let (_, entries, _) = parse_dirstate(&self.content)?;
-        let mut files: Vec<&HgPath> = entries
-            .into_iter()
-            .filter_map(|(path, entry)| match entry.state {
-                EntryState::Removed => None,
-                _ => Some(path),
-            })
-            .collect();
+        let mut files = Vec::new();
+        let _parents = parse_dirstate_entries(
+            &self.content,
+            |path, entry, _copy_source| {
+                if entry.state.is_tracked() {
+                    files.push(path)
+                }
+                Ok(())
+            },
+        )?;
         files.par_sort_unstable();
         Ok(files)
     }



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to