mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 22:37:37 +03:00
exec: Fix low hanging fruit clippy warnings
Summary: **Split from D49099286** Reviewed By: markbt Differential Revision: D49150400 fbshipit-source-id: 82a5918a5de2a83497d25d7722b2596f7c606a13
This commit is contained in:
parent
c32c9b1a06
commit
2e7b63105f
@ -102,7 +102,7 @@ impl ProbePlan {
|
||||
|
||||
pub fn run(self, stats: &Arc<Stats>) {
|
||||
for action in self.0 {
|
||||
action.run(&*stats);
|
||||
action.run(stats);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ impl ProbePlan {
|
||||
let (sender, recv) = mpsc::sync_channel::<ProbeAction>(8);
|
||||
let thread = thread::spawn(move || {
|
||||
for action in recv {
|
||||
action.run(&*stats)
|
||||
action.run(&stats)
|
||||
}
|
||||
});
|
||||
threads.push(thread);
|
||||
@ -144,7 +144,7 @@ impl ProbeAction {
|
||||
if let Some(space) = space {
|
||||
let cmd = &s[..space];
|
||||
let path = &s[space + 1..];
|
||||
if path.len() == 0 {
|
||||
if path.is_empty() {
|
||||
bail!("{} requires path", cmd);
|
||||
}
|
||||
match cmd {
|
||||
|
@ -39,7 +39,7 @@ fn chg_main_wrapper(args: Vec<CString>, envs: Vec<CString>) -> i32 {
|
||||
envp.as_mut_ptr(),
|
||||
name.as_c_str().as_ptr(),
|
||||
)
|
||||
} as i32;
|
||||
};
|
||||
rc
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ fn main() {
|
||||
// Run atexit handlers.
|
||||
atexit::drop_queued();
|
||||
|
||||
std::process::exit(code as i32);
|
||||
std::process::exit(code);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -67,7 +67,7 @@ pub fn zzencode(path: &str) -> String {
|
||||
match b {
|
||||
'/' | '\\' => result.push('Z'),
|
||||
'Z' => result.push_str("_Z"),
|
||||
':' => result.push_str("_"),
|
||||
':' => result.push('_'),
|
||||
_ => result.push(b),
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,12 @@ use serde::Deserialize;
|
||||
|
||||
/// Configuration for scratch space style. This decides whether the directory
|
||||
/// structure is kept exactly as provided subdir or not.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
enum ScratchStyle {
|
||||
/// With flat scratch style, the sub-directories are created one-level under
|
||||
/// the repository namespace with serialized names.
|
||||
#[default]
|
||||
Flat,
|
||||
|
||||
/// With mirror scratch style, the sub-directories mirror the directory
|
||||
@ -50,12 +51,6 @@ enum ScratchStyle {
|
||||
Mirror,
|
||||
}
|
||||
|
||||
impl Default for ScratchStyle {
|
||||
fn default() -> Self {
|
||||
ScratchStyle::Flat
|
||||
}
|
||||
}
|
||||
|
||||
/// The configuration is intentionally very minimal, and explicitly
|
||||
/// not made accessible via command line options; the intent is that
|
||||
/// placement of the scratch space is the policy of the owner of the
|
||||
@ -100,10 +95,7 @@ struct Config {
|
||||
fn home_dir() -> String {
|
||||
let home = dirs::home_dir().expect("resolved HOME dir");
|
||||
home.to_str()
|
||||
.expect(&format!(
|
||||
"HOME dir {:?} was not representable as UTF-8",
|
||||
home
|
||||
))
|
||||
.unwrap_or_else(|| panic!("HOME dir {:?} was not representable as UTF-8", home))
|
||||
.into()
|
||||
}
|
||||
|
||||
@ -136,7 +128,7 @@ impl Config {
|
||||
file.read_to_string(&mut s)?;
|
||||
|
||||
toml::from_str(&s)
|
||||
.map(|c| Some(c))
|
||||
.map(Some)
|
||||
.map_err(|e| format_err!("error while loading TOML from {}: {:?}", path.display(), e))
|
||||
}
|
||||
|
||||
@ -190,8 +182,8 @@ impl Config {
|
||||
return over.clone();
|
||||
}
|
||||
match &self.template {
|
||||
&Some(ref s) => s.clone(),
|
||||
&None => {
|
||||
Some(s) => s.clone(),
|
||||
None => {
|
||||
// This is a little bit of a hack; ideally we'd
|
||||
// configure this in chef, but don't have bandwidth
|
||||
// to prepare a recipe for this in time; will follow
|
||||
@ -522,7 +514,7 @@ fn path_command(
|
||||
let repo_root = locate_repo_root(&path)?.unwrap_or(&path);
|
||||
|
||||
// Get the base scratch path for this repo
|
||||
let mut result = scratch_root(&config, repo_root, encoder)?;
|
||||
let mut result = scratch_root(config, repo_root, encoder)?;
|
||||
readme_in_scratch_path(&result)?;
|
||||
let repo_owner = get_file_owner(repo_root)?;
|
||||
|
||||
@ -548,13 +540,13 @@ fn path_command(
|
||||
ancestors.reverse();
|
||||
for ancestor in ancestors.iter() {
|
||||
match fs::create_dir(ancestor) {
|
||||
Ok(()) => set_file_owner(&ancestor, &repo_owner)?,
|
||||
Ok(()) => set_file_owner(ancestor, &repo_owner)?,
|
||||
Err(_) if ancestor.is_dir() => {}
|
||||
Err(e) => bail!(e),
|
||||
}
|
||||
}
|
||||
if watchable {
|
||||
create_watchmanconfig(&config, &result, &repo_owner)?;
|
||||
create_watchmanconfig(config, &result, &repo_owner)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user