cli: add an early return and reduce indentation
@@ -467,7 +467,9 @@ impl WorkspaceCommandHelper {
}
fn maybe_commit_working_copy(&mut self, ui: &mut Ui) -> Result<(), CommandError> {
- if self.may_update_working_copy {
+ if !self.may_update_working_copy {
+ return Ok(());
+ }
let repo = self.repo.clone();
let workspace_id = self.workspace_id();
let mut locked_wc = self.workspace.working_copy_mut().start_mutation();
@@ -506,8 +508,8 @@ impl WorkspaceCommandHelper {
// copy to what the view says.
writeln!(
ui,
- "The working copy is stale (not updated since operation {}), now \
- updating to operation {}",
+ "The working copy is stale (not updated since operation {}), now updating \
+ to operation {}",
wc_operation.id().hex(),
repo_operation.id().hex()
)?;
@@ -516,16 +518,16 @@ impl WorkspaceCommandHelper {
.unwrap();
} else {
return Err(CommandError::InternalError(format!(
- "The repo was loaded at operation {}, which seems to be a sibling of \
- the working copy's operation {}",
+ "The repo was loaded at operation {}, which seems to be a sibling of the \
+ working copy's operation {}",
repo_operation.id().hex(),
wc_operation.id().hex()
)));
}
} else {
return Err(CommandError::InternalError(format!(
- "The repo was loaded at operation {}, which seems unrelated to the \
- working copy's operation {}",
+ "The repo was loaded at operation {}, which seems unrelated to the working \
+ copy's operation {}",
repo_operation.id().hex(),
wc_operation.id().hex()
)));
@@ -560,7 +562,6 @@ impl WorkspaceCommandHelper {
locked_wc.discard();
}
self.working_copy_committed = true;
- }
Ok(())
}
