Mercurial > public > mercurial-scm > hg-stable
annotate rust/rhg/src/commands/status.rs @ 48397:c12ed33558cb
rhg: Add support for `rhg status -n`
The `RHG_STATUS=1` bit added here can be removed when `unset RHG_STATUS` near
the top of the file is removed.
Differential Revision: https://phab.mercurial-scm.org/D11815
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 26 Nov 2021 15:59:09 +0100 |
parents | d5a91701f7dc |
children | b80e5e75d51e |
rev | line source |
---|---|
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
1 // status.rs |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
2 // |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
3 // Copyright 2020, Georges Racinet <georges.racinets@octobus.net> |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
4 // |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
5 // This software may be used and distributed according to the terms of the |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
6 // GNU General Public License version 2 or any later version. |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
7 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
8 use crate::error::CommandError; |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
9 use crate::ui::Ui; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
10 use crate::utils::path_utils::relativize_paths; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
11 use clap::{Arg, SubCommand}; |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
12 use format_bytes::format_bytes; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
13 use hg; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
14 use hg::config::Config; |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
15 use hg::dirstate::{has_exec_bit, TruncatedTimestamp}; |
47993
f9e6f2bb721d
rhg: Don?t compare ambiguous files one byte at a time
Simon Sapin <simon.sapin@octobus.net>
parents:
47992
diff
changeset
|
16 use hg::errors::HgError; |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
17 use hg::manifest::Manifest; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
18 use hg::matchers::AlwaysMatcher; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
19 use hg::repo::Repo; |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
20 use hg::utils::files::get_bytes_from_os_string; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
21 use hg::utils::hg_path::{hg_path_to_os_string, HgPath}; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
22 use hg::{HgPathCow, StatusOptions}; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
23 use log::{info, warn}; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
24 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
25 pub const HELP_TEXT: &str = " |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
26 Show changed files in the working directory |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
27 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
28 This is a pure Rust version of `hg status`. |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
29 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
30 Some options might be missing, check the list below. |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
31 "; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
32 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
33 pub fn args() -> clap::App<'static, 'static> { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
34 SubCommand::with_name("status") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
35 .alias("st") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
36 .about(HELP_TEXT) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
37 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
38 Arg::with_name("all") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
39 .help("show status of all files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
40 .short("-A") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
41 .long("--all"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
42 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
43 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
44 Arg::with_name("modified") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
45 .help("show only modified files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
46 .short("-m") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
47 .long("--modified"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
48 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
49 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
50 Arg::with_name("added") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
51 .help("show only added files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
52 .short("-a") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
53 .long("--added"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
54 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
55 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
56 Arg::with_name("removed") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
57 .help("show only removed files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
58 .short("-r") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
59 .long("--removed"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
60 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
61 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
62 Arg::with_name("clean") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
63 .help("show only clean files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
64 .short("-c") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
65 .long("--clean"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
66 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
67 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
68 Arg::with_name("deleted") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
69 .help("show only deleted files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
70 .short("-d") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
71 .long("--deleted"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
72 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
73 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
74 Arg::with_name("unknown") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
75 .help("show only unknown (not tracked) files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
76 .short("-u") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
77 .long("--unknown"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
78 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
79 .arg( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
80 Arg::with_name("ignored") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
81 .help("show only ignored files") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
82 .short("-i") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
83 .long("--ignored"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
84 ) |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
85 .arg( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
86 Arg::with_name("no-status") |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
87 .help("hide status prefix") |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
88 .short("-n") |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
89 .long("--no-status"), |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
90 ) |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
91 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
92 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
93 /// Pure data type allowing the caller to specify file states to display |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
94 #[derive(Copy, Clone, Debug)] |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
95 pub struct DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
96 pub modified: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
97 pub added: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
98 pub removed: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
99 pub clean: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
100 pub deleted: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
101 pub unknown: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
102 pub ignored: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
103 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
104 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
105 pub const DEFAULT_DISPLAY_STATES: DisplayStates = DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
106 modified: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
107 added: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
108 removed: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
109 clean: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
110 deleted: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
111 unknown: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
112 ignored: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
113 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
114 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
115 pub const ALL_DISPLAY_STATES: DisplayStates = DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
116 modified: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
117 added: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
118 removed: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
119 clean: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
120 deleted: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
121 unknown: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
122 ignored: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
123 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
124 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
125 impl DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
126 pub fn is_empty(&self) -> bool { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
127 !(self.modified |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
128 || self.added |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
129 || self.removed |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
130 || self.clean |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
131 || self.deleted |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
132 || self.unknown |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
133 || self.ignored) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
134 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
135 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
136 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
137 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
138 let status_enabled_default = false; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
139 let status_enabled = invocation.config.get_option(b"rhg", b"status")?; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
140 if !status_enabled.unwrap_or(status_enabled_default) { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
141 return Err(CommandError::unsupported( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
142 "status is experimental in rhg (enable it with 'rhg.status = true' \ |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
143 or enable fallback with 'rhg.on-unsupported = fallback')" |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
144 )); |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
145 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
146 |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
147 // TODO: lift these limitations |
48386
3bd62274cbc9
rhg: Propagate config errors in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
48309
diff
changeset
|
148 if invocation.config.get_bool(b"ui", b"tweakdefaults")? { |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
149 return Err(CommandError::unsupported( |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
150 "ui.tweakdefaults is not yet supported with rhg status", |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
151 )); |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
152 } |
48386
3bd62274cbc9
rhg: Propagate config errors in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
48309
diff
changeset
|
153 if invocation.config.get_bool(b"ui", b"statuscopies")? { |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
154 return Err(CommandError::unsupported( |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
155 "ui.statuscopies is not yet supported with rhg status", |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
156 )); |
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
157 } |
48387
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
158 if invocation |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
159 .config |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
160 .get(b"commands", b"status.terse") |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
161 .is_some() |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
162 { |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
163 return Err(CommandError::unsupported( |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
164 "status.terse is not yet supported with rhg status", |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
165 )); |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
166 } |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
167 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
168 let ui = invocation.ui; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
169 let config = invocation.config; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
170 let args = invocation.subcommand_args; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
171 let display_states = if args.is_present("all") { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
172 // TODO when implementing `--quiet`: it excludes clean files |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
173 // from `--all` |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
174 ALL_DISPLAY_STATES |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
175 } else { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
176 let requested = DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
177 modified: args.is_present("modified"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
178 added: args.is_present("added"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
179 removed: args.is_present("removed"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
180 clean: args.is_present("clean"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
181 deleted: args.is_present("deleted"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
182 unknown: args.is_present("unknown"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
183 ignored: args.is_present("ignored"), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
184 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
185 if requested.is_empty() { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
186 DEFAULT_DISPLAY_STATES |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
187 } else { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
188 requested |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
189 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
190 }; |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
191 let no_status = args.is_present("no-status"); |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
192 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
193 let repo = invocation.repo?; |
47984
81aedf1fc897
rust: Add Repo::dirstate_map and use it in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
194 let mut dmap = repo.dirstate_map_mut()?; |
47674
ff97e793ed36
dirstate-v2: Introduce a docket file
Simon Sapin <simon.sapin@octobus.net>
parents:
47380
diff
changeset
|
195 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
196 let options = StatusOptions { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
197 // TODO should be provided by the dirstate parsing and |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
198 // hence be stored on dmap. Using a value that assumes we aren't |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
199 // below the time resolution granularity of the FS and the |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
200 // dirstate. |
48271
269ff8978086
dirstate: store mtimes with nanosecond precision in memory
Simon Sapin <simon.sapin@octobus.net>
parents:
48188
diff
changeset
|
201 last_normal_time: TruncatedTimestamp::new_truncate(0, 0), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
202 // we're currently supporting file systems with exec flags only |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
203 // anyway |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
204 check_exec: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
205 list_clean: display_states.clean, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
206 list_unknown: display_states.unknown, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
207 list_ignored: display_states.ignored, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
208 collect_traversed_dirs: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
209 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
210 let ignore_file = repo.working_directory_vfs().join(".hgignore"); // TODO hardcoded |
47984
81aedf1fc897
rust: Add Repo::dirstate_map and use it in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
211 let (mut ds_status, pattern_warnings) = dmap.status( |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
212 &AlwaysMatcher, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
213 repo.working_directory_path().to_owned(), |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
214 vec![ignore_file], |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
215 options, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
216 )?; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
217 if !pattern_warnings.is_empty() { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
218 warn!("Pattern warnings: {:?}", &pattern_warnings); |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
219 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
220 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
221 if !ds_status.bad.is_empty() { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
222 warn!("Bad matches {:?}", &(ds_status.bad)) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
223 } |
47124
9c6b458a08e1
rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46822
diff
changeset
|
224 if !ds_status.unsure.is_empty() { |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
225 info!( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
226 "Files to be rechecked by retrieval from filelog: {:?}", |
47124
9c6b458a08e1
rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46822
diff
changeset
|
227 &ds_status.unsure |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
228 ); |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
229 } |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
230 if !ds_status.unsure.is_empty() |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
231 && (display_states.modified || display_states.clean) |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
232 { |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
233 let p1 = repo.dirstate_parents()?.p1; |
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
234 let manifest = repo.manifest_for_node(p1).map_err(|e| { |
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
235 CommandError::from((e, &*format!("{:x}", p1.short()))) |
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
236 })?; |
47124
9c6b458a08e1
rust: Move "lookup" a.k.a. "unsure" paths into `DirstateStatus` struct
Simon Sapin <simon.sapin@octobus.net>
parents:
46822
diff
changeset
|
237 for to_check in ds_status.unsure { |
48393
b6d8eea9872c
rhg: Rename cat_file_is_modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48392
diff
changeset
|
238 if unsure_is_modified(repo, &manifest, &to_check)? { |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
239 if display_states.modified { |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
240 ds_status.modified.push(to_check); |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
241 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
242 } else { |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
243 if display_states.clean { |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
244 ds_status.clean.push(to_check); |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
245 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
246 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
247 } |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
248 } |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
249 if display_states.modified { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
250 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
251 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
252 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
253 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
254 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
255 &mut ds_status.modified, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
256 b"M", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
257 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
258 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
259 if display_states.added { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
260 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
261 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
262 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
263 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
264 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
265 &mut ds_status.added, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
266 b"A", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
267 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
268 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
269 if display_states.removed { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
270 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
271 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
272 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
273 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
274 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
275 &mut ds_status.removed, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
276 b"R", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
277 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
278 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
279 if display_states.deleted { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
280 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
281 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
282 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
283 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
284 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
285 &mut ds_status.deleted, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
286 b"!", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
287 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
288 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
289 if display_states.unknown { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
290 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
291 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
292 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
293 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
294 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
295 &mut ds_status.unknown, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
296 b"?", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
297 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
298 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
299 if display_states.ignored { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
300 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
301 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
302 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
303 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
304 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
305 &mut ds_status.ignored, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
306 b"I", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
307 )?; |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
308 } |
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
309 if display_states.clean { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
310 display_status_paths( |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
311 ui, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
312 repo, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
313 config, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
314 no_status, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
315 &mut ds_status.clean, |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
316 b"C", |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
317 )?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
318 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
319 Ok(()) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
320 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
321 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
322 // Probably more elegant to use a Deref or Borrow trait rather than |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
323 // harcode HgPathBuf, but probably not really useful at this point |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
324 fn display_status_paths( |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
325 ui: &Ui, |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
326 repo: &Repo, |
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
327 config: &Config, |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
328 no_status: bool, |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
329 paths: &mut [HgPathCow], |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
330 status_prefix: &[u8], |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
331 ) -> Result<(), CommandError> { |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
332 paths.sort_unstable(); |
48386
3bd62274cbc9
rhg: Propagate config errors in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
48309
diff
changeset
|
333 let mut relative: bool = config.get_bool(b"ui", b"relative-paths")?; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
334 relative = config |
48386
3bd62274cbc9
rhg: Propagate config errors in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
48309
diff
changeset
|
335 .get_option(b"commands", b"status.relative")? |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
336 .unwrap_or(relative); |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
337 let print_path = |path: &[u8]| { |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
338 // TODO optim, probably lots of unneeded copies here, especially |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
339 // if out stream is buffered |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
340 if no_status { |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
341 ui.write_stdout(&format_bytes!(b"{}\n", path)) |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
342 } else { |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
343 ui.write_stdout(&format_bytes!(b"{} {}\n", status_prefix, path)) |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
344 } |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
345 }; |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
346 |
48188
38deb65d4441
rhg: add ui.plain() and check it before showing relative paths in status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48187
diff
changeset
|
347 if relative && !ui.plain() { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
348 relativize_paths(repo, paths.iter().map(Ok), |path| { |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
349 print_path(&path) |
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
350 })?; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
351 } else { |
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
352 for path in paths { |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
353 print_path(path.as_bytes())? |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
354 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
355 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
356 Ok(()) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
357 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
358 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
359 /// Check if a file is modified by comparing actual repo store and file system. |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
360 /// |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
361 /// This meant to be used for those that the dirstate cannot resolve, due |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
362 /// to time resolution limits. |
48393
b6d8eea9872c
rhg: Rename cat_file_is_modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48392
diff
changeset
|
363 fn unsure_is_modified( |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
364 repo: &Repo, |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
365 manifest: &Manifest, |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
366 hg_path: &HgPath, |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
367 ) -> Result<bool, HgError> { |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
368 let vfs = repo.working_directory_vfs(); |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
369 let fs_path = hg_path_to_os_string(hg_path).expect("HgPath conversion"); |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
370 let fs_metadata = vfs.symlink_metadata(&fs_path)?; |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
371 let is_symlink = fs_metadata.file_type().is_symlink(); |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
372 // TODO: Also account for `FALLBACK_SYMLINK` and `FALLBACK_EXEC` from the dirstate |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
373 let fs_flags = if is_symlink { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
374 Some(b'l') |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
375 } else if has_exec_bit(&fs_metadata) { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
376 Some(b'x') |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
377 } else { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
378 None |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
379 }; |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
380 |
48392
eb428010aad2
rhg: Also parse flags in the manifest parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48391
diff
changeset
|
381 let entry = manifest |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
382 .find_file(hg_path)? |
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
383 .expect("ambgious file not in p1"); |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
384 if entry.flags != fs_flags { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
385 return Ok(true); |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
386 } |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
387 let filelog = repo.filelog(hg_path)?; |
48392
eb428010aad2
rhg: Also parse flags in the manifest parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48391
diff
changeset
|
388 let filelog_entry = |
eb428010aad2
rhg: Also parse flags in the manifest parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48391
diff
changeset
|
389 filelog.data_for_node(entry.node_id()?).map_err(|_| { |
eb428010aad2
rhg: Also parse flags in the manifest parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48391
diff
changeset
|
390 HgError::corrupted("filelog missing node from manifest") |
eb428010aad2
rhg: Also parse flags in the manifest parser
Simon Sapin <simon.sapin@octobus.net>
parents:
48391
diff
changeset
|
391 })?; |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
392 let contents_in_p1 = filelog_entry.data()?; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
393 |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
394 let fs_contents = if is_symlink { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
395 get_bytes_from_os_string(vfs.read_link(fs_path)?.into_os_string()) |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
396 } else { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
397 vfs.read(fs_path)? |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
398 }; |
48309
594cf89047c8
rhg: Fix `rhg status` file content comparison
Simon Sapin <simon.sapin@octobus.net>
parents:
48271
diff
changeset
|
399 return Ok(contents_in_p1 != &*fs_contents); |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
400 } |