diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 33ca5c1eb..9be3d3e99 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -337,13 +337,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { old_commit_id: &CommitId, new_commit_id: &CommitId, ) -> Result<(), BackendError> { - let mut workspaces_to_update = vec![]; - for (workspace_id, checkout_id) in self.mut_repo.view().checkouts() { - if checkout_id == old_commit_id { - workspaces_to_update.push(workspace_id.clone()); - } - } - + let workspaces_to_update = self.mut_repo.view().workspaces_for_checkout(old_commit_id); if workspaces_to_update.is_empty() { return Ok(()); } diff --git a/lib/src/view.rs b/lib/src/view.rs index baa3615df..dc983b8ca 100644 --- a/lib/src/view.rs +++ b/lib/src/view.rs @@ -50,6 +50,16 @@ impl View { self.data.checkouts.get(workspace_id) } + pub fn workspaces_for_checkout(&self, commit_id: &CommitId) -> Vec { + let mut workspaces_ids = vec![]; + for (workspace_id, checkout_id) in &self.data.checkouts { + if checkout_id == commit_id { + workspaces_ids.push(workspace_id.clone()); + } + } + workspaces_ids + } + pub fn is_checkout(&self, commit_id: &CommitId) -> bool { self.data.checkouts.values().contains(commit_id) }