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

repo: add a function for getting workspaces by checkout

This commit is contained in:
Martin von Zweigbergk 2022-06-23 01:06:20 -07:00 committed by Martin von Zweigbergk
parent 0e812220af
commit b0912b3199
2 changed files with 11 additions and 7 deletions

View file

@ -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(());
}

View file

@ -50,6 +50,16 @@ impl View {
self.data.checkouts.get(workspace_id)
}
pub fn workspaces_for_checkout(&self, commit_id: &CommitId) -> Vec<WorkspaceId> {
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)
}