Mercurial > public > mercurial-scm > hg-stable
annotate rust/rhg/src/commands/status.rs @ 50252:a6b8b1ab9116
branching: merge stable into default
The clippy god had to be appeased on some aspect.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Mar 2023 19:02:52 +0100 |
parents | 1cffc156f7cd 8fcd5302243a |
children | 668a871454e8 98fc949bec14 |
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; |
50037
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
9 use crate::ui::{ |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
10 format_pattern_file_warning, print_narrow_sparse_warnings, Ui, |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
11 }; |
48492
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
12 use crate::utils::path_utils::RelativizePaths; |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
13 use clap::Arg; |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
14 use format_bytes::format_bytes; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
15 use hg::config::Config; |
48439
b80e5e75d51e
dirstate: remove `lastnormaltime` mechanism
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48397
diff
changeset
|
16 use hg::dirstate::has_exec_bit; |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
17 use hg::dirstate::status::StatusPath; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
18 use hg::dirstate::TruncatedTimestamp; |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
19 use hg::errors::{HgError, IoResultExt}; |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
20 use hg::lock::LockError; |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
21 use hg::manifest::Manifest; |
49502
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
22 use hg::matchers::{AlwaysMatcher, IntersectionMatcher}; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
23 use hg::repo::Repo; |
49673
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
24 use hg::utils::debug::debug_wait_for_file; |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
25 use hg::utils::files::get_bytes_from_os_string; |
48490
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
26 use hg::utils::files::get_path_from_bytes; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
27 use hg::utils::hg_path::{hg_path_to_path_buf, HgPath}; |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
28 use hg::DirstateStatus; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
29 use hg::PatternFileWarning; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
30 use hg::StatusError; |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
31 use hg::StatusOptions; |
49502
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
32 use hg::{self, narrow, sparse}; |
48548
c9abfb80b4e3
rhg: Properly format warnings related to ignore patterns
Simon Sapin <simon.sapin@octobus.net>
parents:
48538
diff
changeset
|
33 use log::info; |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
34 use rayon::prelude::*; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
35 use std::io; |
48490
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
36 use std::path::PathBuf; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
37 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
38 pub const HELP_TEXT: &str = " |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
39 Show changed files in the working directory |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
40 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
41 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
|
42 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
43 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
|
44 "; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
45 |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
46 pub fn args() -> clap::Command { |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
47 clap::command!("status") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
48 .alias("st") |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
49 .about(HELP_TEXT) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
50 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
51 Arg::new("all") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
52 .help("show status of all files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
53 .short('A') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
54 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
55 .long("all"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
56 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
57 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
58 Arg::new("modified") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
59 .help("show only modified files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
60 .short('m') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
61 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
62 .long("modified"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
63 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
64 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
65 Arg::new("added") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
66 .help("show only added files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
67 .short('a') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
68 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
69 .long("added"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
70 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
71 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
72 Arg::new("removed") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
73 .help("show only removed files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
74 .short('r') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
75 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
76 .long("removed"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
77 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
78 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
79 Arg::new("clean") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
80 .help("show only clean files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
81 .short('c') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
82 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
83 .long("clean"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
84 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
85 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
86 Arg::new("deleted") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
87 .help("show only deleted files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
88 .short('d') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
89 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
90 .long("deleted"), |
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 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
93 Arg::new("unknown") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
94 .help("show only unknown (not tracked) files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
95 .short('u') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
96 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
97 .long("unknown"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
98 ) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
99 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
100 Arg::new("ignored") |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
101 .help("show only ignored files") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
102 .short('i') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
103 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
104 .long("ignored"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
105 ) |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
106 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
107 Arg::new("copies") |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
108 .help("show source of copied files (DEFAULT: ui.statuscopies)") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
109 .short('C') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
110 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
111 .long("copies"), |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
112 ) |
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
113 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
114 Arg::new("no-status") |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
115 .help("hide status prefix") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
116 .short('n') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
117 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
118 .long("no-status"), |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
119 ) |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
120 .arg( |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
121 Arg::new("verbose") |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
122 .help("enable additional output") |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
123 .short('v') |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
124 .action(clap::ArgAction::SetTrue) |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
125 .long("verbose"), |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
126 ) |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
127 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
128 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
129 /// 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
|
130 #[derive(Copy, Clone, Debug)] |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
131 pub struct DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
132 pub modified: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
133 pub added: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
134 pub removed: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
135 pub clean: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
136 pub deleted: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
137 pub unknown: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
138 pub ignored: bool, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
139 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
140 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
141 pub const DEFAULT_DISPLAY_STATES: DisplayStates = DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
142 modified: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
143 added: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
144 removed: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
145 clean: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
146 deleted: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
147 unknown: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
148 ignored: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
149 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
150 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
151 pub const ALL_DISPLAY_STATES: DisplayStates = DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
152 modified: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
153 added: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
154 removed: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
155 clean: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
156 deleted: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
157 unknown: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
158 ignored: true, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
159 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
160 |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
161 impl DisplayStates { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
162 pub fn is_empty(&self) -> bool { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
163 !(self.modified |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
164 || self.added |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
165 || self.removed |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
166 || self.clean |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
167 || self.deleted |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
168 || self.unknown |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
169 || self.ignored) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
170 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
171 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
172 |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
173 fn has_unfinished_merge(repo: &Repo) -> Result<bool, CommandError> { |
49987
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
174 Ok(repo.dirstate_parents()?.is_merge()) |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
175 } |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
176 |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
177 fn has_unfinished_state(repo: &Repo) -> Result<bool, CommandError> { |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
178 // These are all the known values for the [fname] argument of |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
179 // [addunfinished] function in [state.py] |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
180 let known_state_files: &[&str] = &[ |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
181 "bisect.state", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
182 "graftstate", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
183 "histedit-state", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
184 "rebasestate", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
185 "shelvedstate", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
186 "transplant/journal", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
187 "updatestate", |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
188 ]; |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
189 if has_unfinished_merge(repo)? { |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
190 return Ok(true); |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
191 }; |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
192 for f in known_state_files { |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
193 if repo.hg_vfs().join(f).exists() { |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
194 return Ok(true); |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
195 } |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
196 } |
49987
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
197 Ok(false) |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
198 } |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
199 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
200 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
201 // TODO: lift these limitations |
48387
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
202 if invocation |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
203 .config |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
204 .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
|
205 .is_some() |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
206 { |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
207 return Err(CommandError::unsupported( |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
208 "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
|
209 )); |
f9db8eeb3aec
rhg: Config commands.status.terse is not supported
Simon Sapin <simon.sapin@octobus.net>
parents:
48386
diff
changeset
|
210 } |
48183
64b8676f11bb
rhg: fallback if tweakdefaults or statuscopies is enabled with status
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48084
diff
changeset
|
211 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
212 let ui = invocation.ui; |
48187
707c58880cd0
rhg: add relative paths support in `rhg status`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48183
diff
changeset
|
213 let config = invocation.config; |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
214 let args = invocation.subcommand_args; |
48550
47f2a82ae3e4
rhg: Fall back to Python if verbose status is requested by config
Simon Sapin <simon.sapin@octobus.net>
parents:
48548
diff
changeset
|
215 |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
216 // TODO add `!args.get_flag("print0") &&` when we support `print0` |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
217 let verbose = args.get_flag("verbose") |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
218 || config.get_bool(b"ui", b"verbose")? |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
219 || config.get_bool(b"commands", b"status.verbose")?; |
48550
47f2a82ae3e4
rhg: Fall back to Python if verbose status is requested by config
Simon Sapin <simon.sapin@octobus.net>
parents:
48548
diff
changeset
|
220 |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
221 let all = args.get_flag("all"); |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
222 let display_states = if all { |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
223 // 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
|
224 // from `--all` |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
225 ALL_DISPLAY_STATES |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
226 } else { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
227 let requested = DisplayStates { |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
228 modified: args.get_flag("modified"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
229 added: args.get_flag("added"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
230 removed: args.get_flag("removed"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
231 clean: args.get_flag("clean"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
232 deleted: args.get_flag("deleted"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
233 unknown: args.get_flag("unknown"), |
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
234 ignored: args.get_flag("ignored"), |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
235 }; |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
236 if requested.is_empty() { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
237 DEFAULT_DISPLAY_STATES |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
238 } else { |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
239 requested |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
240 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
241 }; |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
242 let no_status = args.get_flag("no-status"); |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
243 let list_copies = all |
49758
37bc3edef76f
rhg: upgrade `clap` dependency
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
244 || args.get_flag("copies") |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
245 || config.get_bool(b"ui", b"statuscopies")?; |
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 let repo = invocation.repo?; |
48457
005ae1a343f8
rhg: add support for narrow clones and sparse checkouts
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
48439
diff
changeset
|
248 |
49987
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
249 if verbose && has_unfinished_state(repo)? { |
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
250 return Err(CommandError::unsupported( |
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
251 "verbose status output is not supported by rhg (and is needed because we're in an unfinished operation)", |
58074252db3c
rust: run `cargo clippy`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49970
diff
changeset
|
252 )); |
49465
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
253 } |
b07465adbcc8
rhg: make [rhg status -v] work when it needs no extra output
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49373
diff
changeset
|
254 |
47984
81aedf1fc897
rust: Add Repo::dirstate_map and use it in `rhg status`
Simon Sapin <simon.sapin@octobus.net>
parents:
47682
diff
changeset
|
255 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
|
256 |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
257 let check_exec = hg::checkexec::check_exec(repo.working_directory_path()); |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
258 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
259 let options = StatusOptions { |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
260 check_exec, |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
261 list_clean: display_states.clean, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
262 list_unknown: display_states.unknown, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
263 list_ignored: display_states.ignored, |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
264 list_copies, |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
265 collect_traversed_dirs: false, |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
266 }; |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
267 |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
268 type StatusResult<'a> = |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
269 Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
270 |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
271 let after_status = |res: StatusResult| -> Result<_, CommandError> { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
272 let (mut ds_status, pattern_warnings) = res?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
273 for warning in pattern_warnings { |
50037
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
274 ui.write_stderr(&format_pattern_file_warning(&warning, repo))?; |
48548
c9abfb80b4e3
rhg: Properly format warnings related to ignore patterns
Simon Sapin <simon.sapin@octobus.net>
parents:
48538
diff
changeset
|
275 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
276 |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
277 for (path, error) in ds_status.bad { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
278 let error = match error { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
279 hg::BadMatch::OsError(code) => { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
280 std::io::Error::from_raw_os_error(code).to_string() |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
281 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
282 hg::BadMatch::BadType(ty) => { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
283 format!("unsupported file type (type is {})", ty) |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
284 } |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
285 }; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
286 ui.write_stderr(&format_bytes!( |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
287 b"{}: {}\n", |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
288 path.as_bytes(), |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
289 error.as_bytes() |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
290 ))? |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
291 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
292 if !ds_status.unsure.is_empty() { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
293 info!( |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
294 "Files to be rechecked by retrieval from filelog: {:?}", |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
295 ds_status.unsure.iter().map(|s| &s.path).collect::<Vec<_>>() |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
296 ); |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
297 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
298 let mut fixup = Vec::new(); |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
299 if !ds_status.unsure.is_empty() |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
300 && (display_states.modified || display_states.clean) |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
301 { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
302 let p1 = repo.dirstate_parents()?.p1; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
303 let manifest = repo.manifest_for_node(p1).map_err(|e| { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
304 CommandError::from((e, &*format!("{:x}", p1.short()))) |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
305 })?; |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
306 let working_directory_vfs = repo.working_directory_vfs(); |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
307 let store_vfs = repo.store_vfs(); |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
308 let res: Vec<_> = ds_status |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
309 .unsure |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
310 .into_par_iter() |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
311 .map(|to_check| { |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
312 // The compiler seems to get a bit confused with complex |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
313 // inference when using a parallel iterator + map |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
314 // + map_err + collect, so let's just inline some of the |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
315 // logic. |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
316 match unsure_is_modified( |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
317 working_directory_vfs, |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
318 store_vfs, |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
319 check_exec, |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
320 &manifest, |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
321 &to_check.path, |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
322 ) { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
323 Err(HgError::IoError { .. }) => { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
324 // IO errors most likely stem from the file being |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
325 // deleted even though we know it's in the |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
326 // dirstate. |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
327 Ok((to_check, UnsureOutcome::Deleted)) |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
328 } |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
329 Ok(outcome) => Ok((to_check, outcome)), |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
330 Err(e) => Err(e), |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
331 } |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
332 }) |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
333 .collect::<Result<_, _>>()?; |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
334 for (status_path, outcome) in res.into_iter() { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
335 match outcome { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
336 UnsureOutcome::Clean => { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
337 if display_states.clean { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
338 ds_status.clean.push(status_path.clone()); |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
339 } |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
340 fixup.push(status_path.path.into_owned()) |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
341 } |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
342 UnsureOutcome::Modified => { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
343 if display_states.modified { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
344 ds_status.modified.push(status_path); |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
345 } |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
346 } |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
347 UnsureOutcome::Deleted => { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
348 if display_states.deleted { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
349 ds_status.deleted.push(status_path); |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
350 } |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
351 } |
47329
62225f9da938
rhg: Sort `rhg status` output correctly
Simon Sapin <simon.sapin@octobus.net>
parents:
47124
diff
changeset
|
352 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
353 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
354 } |
49517
6939d5ed20e0
rhg: central treatment of PLAIN and PLAINEXCEPT
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49502
diff
changeset
|
355 let relative_paths = config |
6939d5ed20e0
rhg: central treatment of PLAIN and PLAINEXCEPT
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49502
diff
changeset
|
356 .get_option(b"commands", b"status.relative")? |
6939d5ed20e0
rhg: central treatment of PLAIN and PLAINEXCEPT
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49502
diff
changeset
|
357 .unwrap_or(config.get_bool(b"ui", b"relative-paths")?); |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
358 let output = DisplayStatusPaths { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
359 ui, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
360 no_status, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
361 relativize: if relative_paths { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
362 Some(RelativizePaths::new(repo)?) |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
363 } else { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
364 None |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
365 }, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
366 }; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
367 if display_states.modified { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
368 output.display(b"M ", "status.modified", ds_status.modified)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
369 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
370 if display_states.added { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
371 output.display(b"A ", "status.added", ds_status.added)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
372 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
373 if display_states.removed { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
374 output.display(b"R ", "status.removed", ds_status.removed)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
375 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
376 if display_states.deleted { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
377 output.display(b"! ", "status.deleted", ds_status.deleted)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
378 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
379 if display_states.unknown { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
380 output.display(b"? ", "status.unknown", ds_status.unknown)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
381 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
382 if display_states.ignored { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
383 output.display(b"I ", "status.ignored", ds_status.ignored)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
384 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
385 if display_states.clean { |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
386 output.display(b"C ", "status.clean", ds_status.clean)?; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
387 } |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
388 |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
389 let dirstate_write_needed = ds_status.dirty; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
390 let filesystem_time_at_status_start = |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
391 ds_status.filesystem_time_at_status_start; |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
392 |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
393 Ok(( |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
394 fixup, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
395 dirstate_write_needed, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
396 filesystem_time_at_status_start, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
397 )) |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
398 }; |
49502
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
399 let (narrow_matcher, narrow_warnings) = narrow::matcher(repo)?; |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
400 let (sparse_matcher, sparse_warnings) = sparse::matcher(repo)?; |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
401 let matcher = match (repo.has_narrow(), repo.has_sparse()) { |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
402 (true, true) => { |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
403 Box::new(IntersectionMatcher::new(narrow_matcher, sparse_matcher)) |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
404 } |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
405 (true, false) => narrow_matcher, |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
406 (false, true) => sparse_matcher, |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
407 (false, false) => Box::new(AlwaysMatcher), |
7c93e38a0bbd
rhg-status: add support for narrow clones
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49499
diff
changeset
|
408 }; |
49499
ffd4b1f1c9cb
rhg: add sparse support
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49497
diff
changeset
|
409 |
50037
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
410 print_narrow_sparse_warnings( |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
411 &narrow_warnings, |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
412 &sparse_warnings, |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
413 ui, |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
414 repo, |
364e78389653
rust-ui: refactor ui code for printing narrow/sparse warnings
Rapha?l Gom?s <rgomes@octobus.net>
parents:
50015
diff
changeset
|
415 )?; |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
416 let (fixup, mut dirstate_write_needed, filesystem_time_at_status_start) = |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
417 dmap.with_status( |
49499
ffd4b1f1c9cb
rhg: add sparse support
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49497
diff
changeset
|
418 matcher.as_ref(), |
48825
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
419 repo.working_directory_path().to_owned(), |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
420 ignore_files(repo, config), |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
421 options, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
422 after_status, |
dd6b67d5c256
rust: fix unsound `OwningDirstateMap`
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48748
diff
changeset
|
423 )?; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
424 |
49673
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
425 // Development config option to test write races |
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
426 if let Err(e) = |
50252
a6b8b1ab9116
branching: merge stable into default
Pierre-Yves David <pierre-yves.david@octobus.net>
diff
changeset
|
427 debug_wait_for_file(config, "status.pre-dirstate-write-file") |
49673
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
428 { |
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
429 ui.write_stderr(e.as_bytes()).ok(); |
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
430 } |
ae61851e6fe2
dirstate: add a way to test races happening during status
Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49667
diff
changeset
|
431 |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
432 if (fixup.is_empty() || filesystem_time_at_status_start.is_none()) |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
433 && !dirstate_write_needed |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
434 { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
435 // Nothing to update |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
436 return Ok(()); |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
437 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
438 |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
439 // Update the dirstate on disk if we can |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
440 let with_lock_result = |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
441 repo.try_with_wlock_no_wait(|| -> Result<(), CommandError> { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
442 if let Some(mtime_boundary) = filesystem_time_at_status_start { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
443 for hg_path in fixup { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
444 use std::os::unix::fs::MetadataExt; |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
445 let fs_path = hg_path_to_path_buf(&hg_path) |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
446 .expect("HgPath conversion"); |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
447 // Specifically do not reuse `fs_metadata` from |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
448 // `unsure_is_clean` which was needed before reading |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
449 // contents. Here we access metadata again after reading |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
450 // content, in case it changed in the meantime. |
49683
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
451 let metadata_res = repo |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
452 .working_directory_vfs() |
49683
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
453 .symlink_metadata(&fs_path); |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
454 let fs_metadata = match metadata_res { |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
455 Ok(meta) => meta, |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
456 Err(err) => match err { |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
457 HgError::IoError { .. } => { |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
458 // The file has probably been deleted. In any |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
459 // case, it was in the dirstate before, so |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
460 // let's ignore the error. |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
461 continue; |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
462 } |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
463 _ => return Err(err.into()), |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
464 }, |
53ca3e3bc013
rhg: fix race when a fixup file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49673
diff
changeset
|
465 }; |
48482
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
466 if let Some(mtime) = |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
467 TruncatedTimestamp::for_reliable_mtime_of( |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
468 &fs_metadata, |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
469 &mtime_boundary, |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
470 ) |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
471 .when_reading_file(&fs_path)? |
112184713852
rhg: Set second_ambiguous as needed in post-status fixup
Simon Sapin <simon.sapin@octobus.net>
parents:
48468
diff
changeset
|
472 { |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
473 let mode = fs_metadata.mode(); |
49165
4d3f6767319f
rhg: use the new `set_clean` API
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48825
diff
changeset
|
474 let size = fs_metadata.len(); |
4d3f6767319f
rhg: use the new `set_clean` API
Rapha?l Gom?s <rgomes@octobus.net>
parents:
48825
diff
changeset
|
475 dmap.set_clean(&hg_path, mode, size as u32, mtime)?; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
476 dirstate_write_needed = true |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
477 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
478 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
479 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
480 drop(dmap); // Avoid "already mutably borrowed" RefCell panics |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
481 if dirstate_write_needed { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
482 repo.write_dirstate()? |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
483 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
484 Ok(()) |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
485 }); |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
486 match with_lock_result { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
487 Ok(closure_result) => closure_result?, |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
488 Err(LockError::AlreadyHeld) => { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
489 // Not updating the dirstate is not ideal but not critical: |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
490 // don’t keep our caller waiting until some other Mercurial |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
491 // process releases the lock. |
49667
baa4e2c93642
rust: add debug log about skipping dirstate update
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49522
diff
changeset
|
492 log::info!("not writing dirstate from `status`: lock is held") |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
493 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
494 Err(LockError::Other(HgError::IoError { error, .. })) |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
495 if error.kind() == io::ErrorKind::PermissionDenied => |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
496 { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
497 // `hg status` on a read-only repository is fine |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
498 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
499 Err(LockError::Other(error)) => { |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
500 // Report other I/O errors |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
501 Err(error)? |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
502 } |
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
503 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
504 Ok(()) |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
505 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
506 |
48490
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
507 fn ignore_files(repo: &Repo, config: &Config) -> Vec<PathBuf> { |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
508 let mut ignore_files = Vec::new(); |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
509 let repo_ignore = repo.working_directory_vfs().join(".hgignore"); |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
510 if repo_ignore.exists() { |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
511 ignore_files.push(repo_ignore) |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
512 } |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
513 for (key, value) in config.iter_section(b"ui") { |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
514 if key == b"ignore" || key.starts_with(b"ignore.") { |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
515 let path = get_path_from_bytes(value); |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
516 // TODO:Â expand "~/" and environment variable here, like Python |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
517 // does with `os.path.expanduser` and `os.path.expandvars` |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
518 |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
519 let joined = repo.working_directory_path().join(path); |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
520 ignore_files.push(joined); |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
521 } |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
522 } |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
523 ignore_files |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
524 } |
4a983b69e519
rhg: Add support for ui.ignore and ui.ignore.* config
Simon Sapin <simon.sapin@octobus.net>
parents:
48482
diff
changeset
|
525 |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
526 struct DisplayStatusPaths<'a> { |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
527 ui: &'a Ui, |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
528 no_status: bool, |
48492
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
529 relativize: Option<RelativizePaths>, |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
530 } |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
531 |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
532 impl DisplayStatusPaths<'_> { |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
533 // Probably more elegant to use a Deref or Borrow trait rather than |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
534 // harcode HgPathBuf, but probably not really useful at this point |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
535 fn display( |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
536 &self, |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
537 status_prefix: &[u8], |
48744
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
538 label: &'static str, |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
539 mut paths: Vec<StatusPath<'_>>, |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
540 ) -> Result<(), CommandError> { |
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
541 paths.sort_unstable(); |
48748
00efd2d5037d
rust: fix code formatting
Simon Sapin <simon.sapin@octobus.net>
parents:
48745
diff
changeset
|
542 // TODO: get the stdout lock once for the whole loop |
00efd2d5037d
rust: fix code formatting
Simon Sapin <simon.sapin@octobus.net>
parents:
48745
diff
changeset
|
543 // instead of in each write |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
544 for StatusPath { path, copy_source } in paths { |
48492
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
545 let relative; |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
546 let path = if let Some(relativize) = &self.relativize { |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
547 relative = relativize.relativize(&path); |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
548 &*relative |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
549 } else { |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
550 path.as_bytes() |
9b0e1f64656f
rhg: refactor relativize_path into a struct + method
Simon Sapin <simon.sapin@octobus.net>
parents:
48491
diff
changeset
|
551 }; |
48744
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
552 // TODO: Add a way to use `write_bytes!` instead of `format_bytes!` |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
553 // in order to stream to stdout instead of allocating an |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
554 // itermediate `Vec<u8>`. |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
555 if !self.no_status { |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
556 self.ui.write_stdout_labelled(status_prefix, label)? |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
557 } |
48744
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
558 self.ui |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
559 .write_stdout_labelled(&format_bytes!(b"{}\n", path), label)?; |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
560 if let Some(source) = copy_source { |
48744
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
561 let label = "status.copied"; |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
562 self.ui.write_stdout_labelled( |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
563 &format_bytes!(b" {}\n", source.as_bytes()), |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
564 label, |
3e2b4bb286e7
rhg: Colorize `rhg status` output when appropriate
Simon Sapin <simon.sapin@octobus.net>
parents:
48739
diff
changeset
|
565 )? |
48493
473af5cbc209
rhg: Add support for `rhg status --copies`
Simon Sapin <simon.sapin@octobus.net>
parents:
48492
diff
changeset
|
566 } |
48397
c12ed33558cb
rhg: Add support for `rhg status -n`
Simon Sapin <simon.sapin@octobus.net>
parents:
48394
diff
changeset
|
567 } |
48491
2afaa0145584
rhg: refactor display_status_paths with a struct for common arguments
Simon Sapin <simon.sapin@octobus.net>
parents:
48490
diff
changeset
|
568 Ok(()) |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
569 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
570 } |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
571 |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
572 /// Outcome of the additional check for an ambiguous tracked file |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
573 enum UnsureOutcome { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
574 /// The file is actually clean |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
575 Clean, |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
576 /// The file has been modified |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
577 Modified, |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
578 /// The file was deleted on disk (or became another type of fs entry) |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
579 Deleted, |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
580 } |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
581 |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
582 /// 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
|
583 /// |
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
584 /// 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
|
585 /// to time resolution limits. |
48393
b6d8eea9872c
rhg: Rename cat_file_is_modified
Simon Sapin <simon.sapin@octobus.net>
parents:
48392
diff
changeset
|
586 fn unsure_is_modified( |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
587 working_directory_vfs: hg::vfs::Vfs, |
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
588 store_vfs: hg::vfs::Vfs, |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
589 check_exec: bool, |
47992
796206e74b10
rhg: Reuse manifest when checking status of multiple ambiguous files
Simon Sapin <simon.sapin@octobus.net>
parents:
47984
diff
changeset
|
590 manifest: &Manifest, |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
591 hg_path: &HgPath, |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
592 ) -> Result<UnsureOutcome, HgError> { |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
593 let vfs = working_directory_vfs; |
48468
000130cfafb6
rhg: Update the dirstate on disk after status
Simon Sapin <simon.sapin@octobus.net>
parents:
48457
diff
changeset
|
594 let fs_path = hg_path_to_path_buf(hg_path).expect("HgPath conversion"); |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
595 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
|
596 let is_symlink = fs_metadata.file_type().is_symlink(); |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
597 |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
598 let entry = manifest |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
599 .find_by_path(hg_path)? |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
600 .expect("ambgious file not in p1"); |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
601 |
48439
b80e5e75d51e
dirstate: remove `lastnormaltime` mechanism
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48397
diff
changeset
|
602 // TODO: Also account for `FALLBACK_SYMLINK` and `FALLBACK_EXEC` from the |
b80e5e75d51e
dirstate: remove `lastnormaltime` mechanism
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48397
diff
changeset
|
603 // dirstate |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
604 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
|
605 Some(b'l') |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
606 } else if check_exec && has_exec_bit(&fs_metadata) { |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
607 Some(b'x') |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
608 } else { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
609 None |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
610 }; |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
611 |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
612 let entry_flags = if check_exec { |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
613 entry.flags |
50015
70b4c7af9cdb
rust-clippy: fix warning about nested ifs
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49987
diff
changeset
|
614 } else if entry.flags == Some(b'x') { |
70b4c7af9cdb
rust-clippy: fix warning about nested ifs
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49987
diff
changeset
|
615 None |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
616 } else { |
50015
70b4c7af9cdb
rust-clippy: fix warning about nested ifs
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49987
diff
changeset
|
617 entry.flags |
49970
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
618 }; |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
619 |
678588b01af1
rhg: implement checkexec to support weird filesystems
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49758
diff
changeset
|
620 if entry_flags != fs_flags { |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
621 return Ok(UnsureOutcome::Modified); |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
622 } |
49522
52464a20add0
rhg: parallellize computation of [unsure_is_modified]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
49521
diff
changeset
|
623 let filelog = hg::filelog::Filelog::open_vfs(&store_vfs, hg_path)?; |
48510
b005d07ded7d
rhg: Skip reading the contents of ambiguous files in some cases
Simon Sapin <simon.sapin@octobus.net>
parents:
48506
diff
changeset
|
624 let fs_len = fs_metadata.len(); |
49373
455fce57e89e
rust: don't swallow valuable error information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49165
diff
changeset
|
625 let file_node = entry.node_id()?; |
455fce57e89e
rust: don't swallow valuable error information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49165
diff
changeset
|
626 let filelog_entry = filelog.entry_for_node(file_node).map_err(|_| { |
455fce57e89e
rust: don't swallow valuable error information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49165
diff
changeset
|
627 HgError::corrupted(format!( |
50146
1cffc156f7cd
rhg: nicer error message
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50037
diff
changeset
|
628 "filelog {:?} missing node {:?} from manifest", |
1cffc156f7cd
rhg: nicer error message
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50037
diff
changeset
|
629 hg_path, file_node |
49373
455fce57e89e
rust: don't swallow valuable error information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49165
diff
changeset
|
630 )) |
455fce57e89e
rust: don't swallow valuable error information
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49165
diff
changeset
|
631 })?; |
48575
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
632 if filelog_entry.file_data_len_not_equal_to(fs_len) { |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
633 // No need to read file contents: |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
634 // it cannot be equal if it has a different length. |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
635 return Ok(UnsureOutcome::Modified); |
48575
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
636 } |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
637 |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
638 let p1_filelog_data = filelog_entry.data()?; |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
639 let p1_contents = p1_filelog_data.file_data()?; |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
640 if p1_contents.len() as u64 != fs_len { |
e91aa800ae5b
rhg: desambiguate status without decompressing filelog if possible
Simon Sapin <simon.sapin@octobus.net>
parents:
48571
diff
changeset
|
641 // No need to read file contents: |
48510
b005d07ded7d
rhg: Skip reading the contents of ambiguous files in some cases
Simon Sapin <simon.sapin@octobus.net>
parents:
48506
diff
changeset
|
642 // it cannot be equal if it has a different length. |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
643 return Ok(UnsureOutcome::Modified); |
48510
b005d07ded7d
rhg: Skip reading the contents of ambiguous files in some cases
Simon Sapin <simon.sapin@octobus.net>
parents:
48506
diff
changeset
|
644 } |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
645 |
48394
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
646 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
|
647 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
|
648 } else { |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
649 vfs.read(fs_path)? |
d5a91701f7dc
rhg: Fix status desambiguation of symlinks and executable files
Simon Sapin <simon.sapin@octobus.net>
parents:
48393
diff
changeset
|
650 }; |
49684
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
651 |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
652 Ok(if p1_contents != &*fs_contents { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
653 UnsureOutcome::Modified |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
654 } else { |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
655 UnsureOutcome::Clean |
8fcd5302243a
rhg: fix race when an ambiguous file is deleted on disk
Rapha?l Gom?s <rgomes@octobus.net>
parents:
49683
diff
changeset
|
656 }) |
46822
c71e8d9e7f2a
rhg: Initial support for the 'status' command
Georges Racinet <georges.racinet@octobus.net>
parents:
diff
changeset
|
657 } |