Mercurial > public > mercurial-scm > hg
annotate rust/rhg/src/commands/debugrhgsparse.rs @ 50215:ae61851e6fe2 stable
dirstate: add a way to test races happening during status
We add the `devel.sync.status.pre-dirstate-write-file` config option to easily
test what happens when other operations happen during the window where
`hg status` is done working but has not updated the cache on disk yet.
We introduce the framework for testing such races too, actual tests will be
added in the next changesets. For now the test is only checking dirstate-v1. We
will extend the test coverage later too.
Check test documentation for details.
Code change from Rapha?l Gom?s <rgomes@octobus.net>
Test change from Pierre-Yves David <pierre-yves.david@octobus.net>
author | Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 28 Feb 2023 15:25:47 +0100 |
parents | 85f5d11c77dd |
children | 37bc3edef76f |
rev | line source |
---|---|
49484
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
1 use std::os::unix::prelude::OsStrExt; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
2 |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
3 use crate::error::CommandError; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
4 use clap::SubCommand; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
5 use hg::{self, utils::hg_path::HgPath}; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
6 |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
7 pub const HELP_TEXT: &str = ""; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
8 |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
9 pub fn args() -> clap::App<'static, 'static> { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
10 SubCommand::with_name("debugrhgsparse") |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
11 .arg( |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
12 clap::Arg::with_name("files") |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
13 .required(true) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
14 .multiple(true) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
15 .empty_values(false) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
16 .value_name("FILES") |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
17 .help("Files to check against sparse profile"), |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
18 ) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
19 .about(HELP_TEXT) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
20 } |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
21 |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
22 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
23 let repo = invocation.repo?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
24 |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
25 let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap(); |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
26 let files = invocation.subcommand_args.values_of_os("files"); |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
27 if let Some(files) = files { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
28 for file in files { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
29 invocation.ui.write_stdout(b"matches: ")?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
30 invocation.ui.write_stdout( |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
31 if matcher.matches(HgPath::new(file.as_bytes())) { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
32 b"yes" |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
33 } else { |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
34 b"no" |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
35 }, |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
36 )?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
37 invocation.ui.write_stdout(b" | file: ")?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
38 invocation.ui.write_stdout(file.as_bytes())?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
39 invocation.ui.write_stdout(b"\n")?; |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
40 } |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
41 } |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
42 Ok(()) |
85f5d11c77dd
rhg: add debugrhgsparse command to help figure out bugs in rhg
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff
changeset
|
43 } |