forked from mirrors/jj
edit: explicitly check that target commit is rewritable
I think the CLI should check if the target of `jj edit` is rewritable before calling the library to update the repo. The other commands already do that. Then, if calling `MutableRepo::edit()` fails, it's always an internal error, which makes error handling simpler in coming commits.
This commit is contained in:
parent
e4f6dadfad
commit
ff592e522f
2 changed files with 2 additions and 1 deletions
|
@ -113,7 +113,7 @@ impl From<crate::config::ConfigError> for CommandError {
|
||||||
|
|
||||||
impl From<RewriteRootCommit> for CommandError {
|
impl From<RewriteRootCommit> for CommandError {
|
||||||
fn from(err: RewriteRootCommit) -> Self {
|
fn from(err: RewriteRootCommit) -> Self {
|
||||||
user_error(err.to_string())
|
CommandError::InternalError(format!("Attempted to rewrite the root commit: {err}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1964,6 +1964,7 @@ fn cmd_abandon(
|
||||||
fn cmd_edit(ui: &mut Ui, command: &CommandHelper, args: &EditArgs) -> Result<(), CommandError> {
|
fn cmd_edit(ui: &mut Ui, command: &CommandHelper, args: &EditArgs) -> Result<(), CommandError> {
|
||||||
let mut workspace_command = command.workspace_helper(ui)?;
|
let mut workspace_command = command.workspace_helper(ui)?;
|
||||||
let new_commit = workspace_command.resolve_single_rev(&args.revision)?;
|
let new_commit = workspace_command.resolve_single_rev(&args.revision)?;
|
||||||
|
workspace_command.check_rewriteable(&new_commit)?;
|
||||||
let workspace_id = workspace_command.workspace_id();
|
let workspace_id = workspace_command.workspace_id();
|
||||||
if workspace_command
|
if workspace_command
|
||||||
.repo()
|
.repo()
|
||||||
|
|
Loading…
Reference in a new issue