diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 633b66691d..aed055107c 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -1313,7 +1313,7 @@ Set which revision the branch points to with `jj branch set {branch_name} -r (repo, wc_commit), WorkingCopyFreshness::Updated(wc_operation) => { let repo = repo.reload_at(&wc_operation)?; @@ -1751,17 +1751,16 @@ pub fn check_stale_working_copy( locked_wc: &dyn LockedWorkingCopy, wc_commit: &Commit, repo: &ReadonlyRepo, -) -> WorkingCopyFreshness { +) -> Result { // Check if the working copy's tree matches the repo's view let wc_tree_id = locked_wc.old_tree_id(); if wc_commit.tree_id() == wc_tree_id { // The working copy isn't stale, and no need to reload the repo. - WorkingCopyFreshness::Fresh + Ok(WorkingCopyFreshness::Fresh) } else { let wc_operation_data = repo .op_store() - .read_operation(locked_wc.old_operation_id()) - .unwrap(); + .read_operation(locked_wc.old_operation_id())?; let wc_operation = Operation::new( repo.op_store().clone(), locked_wc.old_operation_id().clone(), @@ -1778,16 +1777,16 @@ pub fn check_stale_working_copy( if ancestor_op.id() == repo_operation.id() { // The working copy was updated since we loaded the repo. The repo must be // reloaded at the working copy's operation. - WorkingCopyFreshness::Updated(Box::new(wc_operation)) + Ok(WorkingCopyFreshness::Updated(Box::new(wc_operation))) } else if ancestor_op.id() == wc_operation.id() { // The working copy was not updated when some repo operation committed, // meaning that it's stale compared to the repo view. - WorkingCopyFreshness::WorkingCopyStale + Ok(WorkingCopyFreshness::WorkingCopyStale) } else { - WorkingCopyFreshness::SiblingOperation + Ok(WorkingCopyFreshness::SiblingOperation) } } else { - WorkingCopyFreshness::UnrelatedOperation + Ok(WorkingCopyFreshness::UnrelatedOperation) } } } @@ -1945,19 +1944,19 @@ pub fn resolve_all_revs( fn find_all_operations( op_store: &Arc, op_heads_store: &Arc, -) -> Vec { +) -> Result, OpStoreError> { let mut visited = HashSet::new(); let mut work: VecDeque<_> = op_heads_store.get_op_heads().into_iter().collect(); let mut operations = vec![]; while let Some(op_id) = work.pop_front() { if visited.insert(op_id.clone()) { - let store_operation = op_store.read_operation(&op_id).unwrap(); + let store_operation = op_store.read_operation(&op_id)?; work.extend(store_operation.parents.iter().cloned()); let operation = Operation::new(op_store.clone(), op_id, store_operation); operations.push(operation); } } - operations + Ok(operations) } fn resolve_single_op_from_store( @@ -1987,7 +1986,7 @@ fn resolve_single_op_from_store( } } let mut matches = vec![]; - for op in find_all_operations(op_store, op_heads_store) { + for op in find_all_operations(op_store, op_heads_store)? { if op.id().hex().starts_with(op_str) { matches.push(op); } diff --git a/cli/src/commands/workspace.rs b/cli/src/commands/workspace.rs index a4381bf2dc..aa419cc0f0 100644 --- a/cli/src/commands/workspace.rs +++ b/cli/src/commands/workspace.rs @@ -314,7 +314,7 @@ fn cmd_workspace_update_stale( let repo = workspace_command.repo().clone(); let (mut locked_ws, desired_wc_commit) = workspace_command.unchecked_start_working_copy_mutation()?; - if !check_stale_working_copy(locked_ws.locked_wc(), &desired_wc_commit, &repo).is_stale() { + if !check_stale_working_copy(locked_ws.locked_wc(), &desired_wc_commit, &repo)?.is_stale() { writeln!( ui.stderr(), "Nothing to do (the working copy is not stale)."