ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: abbreviate operation id embedded in warning/error messages

Operation id is quite long and these messages looked noisy with the full
hash.
This commit is contained in:
Yuya Nishihara 2022-09-22 18:29:06 +09:00
parent e5da4df243
commit 51cb4d901c

View file

@ -621,8 +621,8 @@ impl WorkspaceCommandHelper {
ui, ui,
"The working copy is stale (not updated since operation {}), now updating \ "The working copy is stale (not updated since operation {}), now updating \
to operation {}", to operation {}",
wc_operation.id().hex(), short_operation_hash(wc_operation.id()),
repo_operation.id().hex() short_operation_hash(repo_operation.id()),
)?; )?;
locked_wc locked_wc
.check_out(&checkout_commit.tree()) .check_out(&checkout_commit.tree())
@ -638,16 +638,16 @@ impl WorkspaceCommandHelper {
return Err(CommandError::InternalError(format!( return Err(CommandError::InternalError(format!(
"The repo was loaded at operation {}, which seems to be a sibling of the \ "The repo was loaded at operation {}, which seems to be a sibling of the \
working copy's operation {}", working copy's operation {}",
repo_operation.id().hex(), short_operation_hash(repo_operation.id()),
wc_operation.id().hex() short_operation_hash(wc_operation.id()),
))); )));
} }
} else { } else {
return Err(CommandError::InternalError(format!( return Err(CommandError::InternalError(format!(
"The repo was loaded at operation {}, which seems unrelated to the working \ "The repo was loaded at operation {}, which seems unrelated to the working \
copy's operation {}", copy's operation {}",
repo_operation.id().hex(), short_operation_hash(repo_operation.id()),
wc_operation.id().hex() short_operation_hash(wc_operation.id()),
))); )));
} }
} }
@ -2117,6 +2117,10 @@ fn short_commit_hash(commit_id: &CommitId) -> String {
commit_id.hex()[0..12].to_string() commit_id.hex()[0..12].to_string()
} }
fn short_operation_hash(operation_id: &OperationId) -> String {
operation_id.hex()[0..12].to_string()
}
fn add_to_git_exclude(ui: &mut Ui, git_repo: &git2::Repository) -> Result<(), CommandError> { fn add_to_git_exclude(ui: &mut Ui, git_repo: &git2::Repository) -> Result<(), CommandError> {
let exclude_file_path = git_repo.path().join("info").join("exclude"); let exclude_file_path = git_repo.path().join("info").join("exclude");
if exclude_file_path.exists() { if exclude_file_path.exists() {