##// END OF EJS Templates
rhg: fix race when an ambiguous file is deleted on disk...
rhg: fix race when an ambiguous file is deleted on disk There are two places in the status code where we handle files whose status we are unsure of based off of metadata alone: this one is the first one to actually disambiguate, and the second one is later in the code (but updated in the previous commit) for files that are actually clean to update the dirstate. Since there is a chance that the contents have changed between those two moments, we need to stat the files again, since re-using the old stat could lie about the clean state of the file.

File last commit:

r50809:58074252 default
r51121:8fcd5302 stable
Show More
debugrhgsparse.rs
43 lines | 1.3 KiB | application/rls-services+xml | RustLexer
use std::os::unix::prelude::OsStrExt;
use crate::error::CommandError;
use clap::SubCommand;
use hg::{self, utils::hg_path::HgPath};
pub const HELP_TEXT: &str = "";
pub fn args() -> clap::App<'static, 'static> {
SubCommand::with_name("debugrhgsparse")
.arg(
clap::Arg::with_name("files")
.required(true)
.multiple(true)
.empty_values(false)
.value_name("FILES")
.help("Files to check against sparse profile"),
)
.about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let repo = invocation.repo?;
let (matcher, _warnings) = hg::sparse::matcher(&repo).unwrap();
let files = invocation.subcommand_args.values_of_os("files");
if let Some(files) = files {
for file in files {
invocation.ui.write_stdout(b"matches: ")?;
invocation.ui.write_stdout(
if matcher.matches(HgPath::new(file.as_bytes())) {
b"yes"
} else {
b"no"
},
)?;
invocation.ui.write_stdout(b" | file: ")?;
invocation.ui.write_stdout(file.as_bytes())?;
invocation.ui.write_stdout(b"\n")?;
}
}
Ok(())
}