rust/rhg/src/commands/files.rs
changeset 48342 10c32e1b892a
parent 48174 9ecf802b06e0
child 48409 005ae1a343f8
equal deleted inserted replaced
48341:51f26c8088b2 48342:10c32e1b892a
     1 use crate::error::CommandError;
     1 use crate::error::CommandError;
     2 use crate::ui::Ui;
     2 use crate::ui::Ui;
     3 use crate::ui::UiError;
     3 use crate::ui::UiError;
     4 use crate::utils::path_utils::relativize_paths;
     4 use crate::utils::path_utils::relativize_paths;
     5 use clap::Arg;
     5 use clap::Arg;
       
     6 use hg::errors::HgError;
     6 use hg::operations::list_rev_tracked_files;
     7 use hg::operations::list_rev_tracked_files;
     7 use hg::operations::Dirstate;
     8 use hg::operations::Dirstate;
     8 use hg::repo::Repo;
     9 use hg::repo::Repo;
     9 use hg::utils::hg_path::HgPath;
    10 use hg::utils::hg_path::HgPath;
    10 use std::borrow::Cow;
    11 use std::borrow::Cow;
    43         let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?;
    44         let files = list_rev_tracked_files(repo, rev).map_err(|e| (e, rev))?;
    44         display_files(invocation.ui, repo, files.iter())
    45         display_files(invocation.ui, repo, files.iter())
    45     } else {
    46     } else {
    46         let distate = Dirstate::new(repo)?;
    47         let distate = Dirstate::new(repo)?;
    47         let files = distate.tracked_files()?;
    48         let files = distate.tracked_files()?;
    48         display_files(invocation.ui, repo, files)
    49         display_files(invocation.ui, repo, files.into_iter().map(Ok))
    49     }
    50     }
    50 }
    51 }
    51 
    52 
    52 fn display_files<'a>(
    53 fn display_files<'a>(
    53     ui: &Ui,
    54     ui: &Ui,
    54     repo: &Repo,
    55     repo: &Repo,
    55     files: impl IntoIterator<Item = &'a HgPath>,
    56     files: impl IntoIterator<Item = Result<&'a HgPath, HgError>>,
    56 ) -> Result<(), CommandError> {
    57 ) -> Result<(), CommandError> {
    57     let mut stdout = ui.stdout_buffer();
    58     let mut stdout = ui.stdout_buffer();
    58     let mut any = false;
    59     let mut any = false;
    59 
    60 
    60     relativize_paths(repo, files, |path: Cow<[u8]>| -> Result<(), UiError> {
    61     relativize_paths(repo, files, |path: Cow<[u8]>| -> Result<(), UiError> {