Mercurial > public > mercurial-scm > hg-stable
annotate rust/rhg/src/commands/files.rs @ 45543:2f8227a12592
rhg: add `--revision` argument to `rhg files`
Add the option to list the tracked files of a revision given its number
or full node id.
Benched on a clone of moz-central
where tip is 1671467:81deaa1a68ebb28db0490954034ab38ab269409d
files -r 81deaa1a68ebb28db0490954034ab38ab269409d > out.txt
hg 0m1.633s
rhg 0m0.157s
files -r 81deaa1a68ebb28db0490954034ab38ab269409d > /dev/null
hg 0m0.415s
rhg 0m0.143s
Differential Revision: https://phab.mercurial-scm.org/D9015
author | Antoine Cezar <antoine.cezar@octobus.net> |
---|---|
date | Wed, 09 Sep 2020 14:53:15 +0200 |
parents | 72b7d58d6e35 |
children | 2ad2745e0be9 |
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 }; |
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
|
14 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
|
15 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
|
16 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
|
17 |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
18 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
|
19 List tracked files. |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
20 |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
21 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
|
22 "; |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
23 |
45543
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
24 pub struct FilesCommand<'a> { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
25 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
|
26 } |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
27 |
45543
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
28 impl<'a> FilesCommand<'a> { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
29 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
|
30 FilesCommand { rev } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
31 } |
45384
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
32 |
45543
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
33 fn display_files( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
34 &self, |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
35 ui: &Ui, |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
36 root: &PathBuf, |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
37 files: impl IntoIterator<Item = &'a HgPath>, |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
38 ) -> 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
|
39 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
|
40 .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
|
41 let rooted_cwd = cwd |
45541
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
42 .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
|
43 .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
|
44 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
|
45 |
45449
ed95ccc94333
rhg: pass `ui` to `Command` `run`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45447
diff
changeset
|
46 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
|
47 |
45384
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 } |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
52 stdout.flush()?; |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
53 Ok(()) |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
54 } |
5fe25f8ef5d9
rhg: add a `Files` `Command` to prepare the `rhg files` subcommand
Antoine Cezar <antoine.cezar@octobus.net>
parents:
diff
changeset
|
55 } |
45541
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
56 |
45543
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
57 impl<'a> Command for FilesCommand<'a> { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
58 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
|
59 let root = FindRoot::new().run()?; |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
60 if let Some(rev) = self.rev { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
61 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
|
62 .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
|
63 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
|
64 self.display_files(ui, &root, files) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
65 } else { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
66 let mut operation = ListDirstateTrackedFiles::new(&root) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
67 .map_err(map_dirstate_error)?; |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
68 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
|
69 self.display_files(ui, &root, files) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
70 } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
71 } |
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 /// Convert `ListRevTrackedFilesErrorKind` to `CommandError` |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
75 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
|
76 CommandError { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
77 kind: match err.kind { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
78 ListRevTrackedFilesErrorKind::IoError(err) => { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
79 CommandErrorKind::Abort(Some( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
80 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
|
81 )) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
82 } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
83 ListRevTrackedFilesErrorKind::InvalidRevision => { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
84 CommandErrorKind::Abort(Some( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
85 utf8_to_local(&format!( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
86 "abort: invalid revision identifier{}\n", |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
87 rev |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
88 )) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
89 .into(), |
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 } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
92 ListRevTrackedFilesErrorKind::UnsuportedRevlogVersion(version) => { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
93 CommandErrorKind::Abort(Some( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
94 utf8_to_local(&format!( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
95 "abort: unsupported revlog version {}\n", |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
96 version |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
97 )) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
98 .into(), |
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 } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
101 ListRevTrackedFilesErrorKind::CorruptedRevlog => { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
102 CommandErrorKind::Abort(Some( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
103 "abort: corrupted revlog\n".into(), |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
104 )) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
105 } |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
106 ListRevTrackedFilesErrorKind::UnknowRevlogDataFormat(format) => { |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
107 CommandErrorKind::Abort(Some( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
108 utf8_to_local(&format!( |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
109 "abort: unknow revlog dataformat {:?}\n", |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
110 format |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
111 )) |
2f8227a12592
rhg: add `--revision` argument to `rhg files`
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45541
diff
changeset
|
112 .into(), |
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 } |
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 /// Convert `ListDirstateTrackedFilesError` to `CommandError` |
45541
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
120 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
|
121 CommandError { |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
122 kind: match err.kind { |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
123 ListDirstateTrackedFilesErrorKind::IoError(err) => { |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
124 CommandErrorKind::Abort(Some( |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
125 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
|
126 )) |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
127 } |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
128 ListDirstateTrackedFilesErrorKind::ParseError(_) => { |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
129 CommandErrorKind::Abort(Some( |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
130 // TODO find a better error message |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
131 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
|
132 )) |
72b7d58d6e35
hg-core: simplify `list_tracked_files` operation
Antoine Cezar <antoine.cezar@octobus.net>
parents:
45449
diff
changeset
|
133 } |
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 } |