annotate rust/rhg/src/commands/files.rs @ 46011:904647f7d983

rhg: add a test for --rev with a hex changeset ID And fix error message formatting Differential Revision: https://phab.mercurial-scm.org/D9478
author Simon Sapin <simon-commits@exyr.org>
date Mon, 30 Nov 2020 19:26:54 +0100
parents 2ad2745e0be9
children 8d6164098782
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
1 use crate::commands::Command;
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
2 use crate::error::{CommandError, CommandErrorKind};
45541
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
3 use crate::ui::utf8_to_local;
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
4 use crate::ui::Ui;
45541
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
5 use hg::operations::FindRoot;
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
6 use hg::operations::{
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
7 ListDirstateTrackedFiles, ListDirstateTrackedFilesError,
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
8 ListDirstateTrackedFilesErrorKind,
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
9 };
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
10 use hg::operations::{
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
11 ListRevTrackedFiles, ListRevTrackedFilesError,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
12 ListRevTrackedFilesErrorKind,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
13 };
45952
2ad2745e0be9 rhg: exit with relevant code for unsupported requirements
Simon Sapin <simon-commits@exyr.org>
parents: 45543
diff changeset
14 use hg::requirements;
45447
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
15 use hg::utils::files::{get_bytes_from_path, relativize_path};
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
16 use hg::utils::hg_path::{HgPath, HgPathBuf};
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
17 use std::path::PathBuf;
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
18
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
19 pub const HELP_TEXT: &str = "
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
20 List tracked files.
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
21
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
22 Returns 0 on success.
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
23 ";
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
24
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
25 pub struct FilesCommand<'a> {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
26 rev: Option<&'a str>,
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
27 }
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
28
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
29 impl<'a> FilesCommand<'a> {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
30 pub fn new(rev: Option<&'a str>) -> Self {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
31 FilesCommand { rev }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
32 }
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
33
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
34 fn display_files(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
35 &self,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
36 ui: &Ui,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
37 root: &PathBuf,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
38 files: impl IntoIterator<Item = &'a HgPath>,
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
39 ) -> Result<(), CommandError> {
45447
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
40 let cwd = std::env::current_dir()
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
41 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?;
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
42 let rooted_cwd = cwd
45541
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
43 .strip_prefix(&root)
45447
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
44 .expect("cwd was already checked within the repository");
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
45 let rooted_cwd = HgPathBuf::from(get_bytes_from_path(rooted_cwd));
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
46
45449
ed95ccc94333 rhg: pass `ui` to `Command` `run`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45447
diff changeset
47 let mut stdout = ui.stdout_buffer();
45447
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
48
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
49 for file in files {
45447
1b3197047f5c rhg: make output of `files` relative to the current directory and the root
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45384
diff changeset
50 stdout.write_all(relativize_path(file, &rooted_cwd).as_ref())?;
45384
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
51 stdout.write_all(b"\n")?;
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
52 }
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
53 stdout.flush()?;
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
54 Ok(())
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
55 }
5fe25f8ef5d9 rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff changeset
56 }
45541
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
57
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
58 impl<'a> Command for FilesCommand<'a> {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
59 fn run(&self, ui: &Ui) -> Result<(), CommandError> {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
60 let root = FindRoot::new().run()?;
45952
2ad2745e0be9 rhg: exit with relevant code for unsupported requirements
Simon Sapin <simon-commits@exyr.org>
parents: 45543
diff changeset
61 requirements::check(&root)?;
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
62 if let Some(rev) = self.rev {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
63 let mut operation = ListRevTrackedFiles::new(&root, rev)
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
64 .map_err(|e| map_rev_error(rev, e))?;
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
65 let files = operation.run().map_err(|e| map_rev_error(rev, e))?;
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
66 self.display_files(ui, &root, files)
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
67 } else {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
68 let mut operation = ListDirstateTrackedFiles::new(&root)
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
69 .map_err(map_dirstate_error)?;
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
70 let files = operation.run().map_err(map_dirstate_error)?;
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
71 self.display_files(ui, &root, files)
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
72 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
73 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
74 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
75
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
76 /// Convert `ListRevTrackedFilesErrorKind` to `CommandError`
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
77 fn map_rev_error(rev: &str, err: ListRevTrackedFilesError) -> CommandError {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
78 CommandError {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
79 kind: match err.kind {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
80 ListRevTrackedFilesErrorKind::IoError(err) => {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
81 CommandErrorKind::Abort(Some(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
82 utf8_to_local(&format!("abort: {}\n", err)).into(),
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
83 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
84 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
85 ListRevTrackedFilesErrorKind::InvalidRevision => {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
86 CommandErrorKind::Abort(Some(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
87 utf8_to_local(&format!(
46011
904647f7d983 rhg: add a test for --rev with a hex changeset ID
Simon Sapin <simon-commits@exyr.org>
parents: 45952
diff changeset
88 "abort: invalid revision identifier {}\n",
45543
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
89 rev
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
90 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
91 .into(),
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
92 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
93 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
94 ListRevTrackedFilesErrorKind::UnsuportedRevlogVersion(version) => {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
95 CommandErrorKind::Abort(Some(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
96 utf8_to_local(&format!(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
97 "abort: unsupported revlog version {}\n",
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
98 version
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
99 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
100 .into(),
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
101 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
102 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
103 ListRevTrackedFilesErrorKind::CorruptedRevlog => {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
104 CommandErrorKind::Abort(Some(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
105 "abort: corrupted revlog\n".into(),
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
106 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
107 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
108 ListRevTrackedFilesErrorKind::UnknowRevlogDataFormat(format) => {
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
109 CommandErrorKind::Abort(Some(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
110 utf8_to_local(&format!(
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
111 "abort: unknow revlog dataformat {:?}\n",
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
112 format
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
113 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
114 .into(),
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
115 ))
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
116 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
117 },
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
118 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
119 }
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
120
2f8227a12592 rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45541
diff changeset
121 /// Convert `ListDirstateTrackedFilesError` to `CommandError`
45541
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
122 fn map_dirstate_error(err: ListDirstateTrackedFilesError) -> CommandError {
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
123 CommandError {
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
124 kind: match err.kind {
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
125 ListDirstateTrackedFilesErrorKind::IoError(err) => {
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
126 CommandErrorKind::Abort(Some(
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
127 utf8_to_local(&format!("abort: {}\n", err)).into(),
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
128 ))
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
129 }
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
130 ListDirstateTrackedFilesErrorKind::ParseError(_) => {
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
131 CommandErrorKind::Abort(Some(
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
132 // TODO find a better error message
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
133 b"abort: parse error\n".to_vec(),
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
134 ))
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
135 }
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
136 },
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
137 }
72b7d58d6e35 hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents: 45449
diff changeset
138 }