##// END OF EJS Templates
tags: take lock instead of wlock before writing hgtagsfnodes1 cache...
tags: take lock instead of wlock before writing hgtagsfnodes1 cache This cache is shared across stores and hence we should take store lock before writing to it. Otherwise there will be race where one share with wlock is writing to this cache and other share with wlock is trying to read it simultaneously. Differential Revision: https://phab.mercurial-scm.org/D9001

File last commit:

r45923:5fe25f8e default
r46005:64de86fd default
Show More
files.rs
50 lines | 1.3 KiB | application/rls-services+xml | RustLexer
use crate::commands::Command;
use crate::error::{CommandError, CommandErrorKind};
use crate::ui::Ui;
use hg::operations::{ListTrackedFiles, ListTrackedFilesErrorKind};
pub const HELP_TEXT: &str = "
List tracked files.
Returns 0 on success.
";
pub struct FilesCommand<'a> {
ui: &'a Ui,
}
impl<'a> FilesCommand<'a> {
pub fn new(ui: &'a Ui) -> Self {
FilesCommand { ui }
}
}
impl<'a> Command<'a> for FilesCommand<'a> {
fn run(&self) -> Result<(), CommandError> {
let operation_builder = ListTrackedFiles::new()?;
let operation = operation_builder.load().map_err(|err| {
CommandErrorKind::Abort(Some(
[b"abort: ", err.to_string().as_bytes(), b"\n"]
.concat()
.to_vec(),
))
})?;
let files = operation.run().map_err(|err| match err.kind {
ListTrackedFilesErrorKind::ParseError(_) => {
CommandErrorKind::Abort(Some(
// TODO find a better error message
b"abort: parse error\n".to_vec(),
))
}
})?;
let mut stdout = self.ui.stdout_buffer();
for file in files {
stdout.write_all(file.as_bytes())?;
stdout.write_all(b"\n")?;
}
stdout.flush()?;
Ok(())
}
}