mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-29 02:51:12 +00:00
repo: add a function for getting workspaces by checkout
This commit is contained in:
parent
0e812220af
commit
b0912b3199
@ -337,13 +337,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
|
|||||||
old_commit_id: &CommitId,
|
old_commit_id: &CommitId,
|
||||||
new_commit_id: &CommitId,
|
new_commit_id: &CommitId,
|
||||||
) -> Result<(), BackendError> {
|
) -> Result<(), BackendError> {
|
||||||
let mut workspaces_to_update = vec![];
|
let workspaces_to_update = self.mut_repo.view().workspaces_for_checkout(old_commit_id);
|
||||||
for (workspace_id, checkout_id) in self.mut_repo.view().checkouts() {
|
|
||||||
if checkout_id == old_commit_id {
|
|
||||||
workspaces_to_update.push(workspace_id.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if workspaces_to_update.is_empty() {
|
if workspaces_to_update.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,16 @@ impl View {
|
|||||||
self.data.checkouts.get(workspace_id)
|
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 {
|
pub fn is_checkout(&self, commit_id: &CommitId) -> bool {
|
||||||
self.data.checkouts.values().contains(commit_id)
|
self.data.checkouts.values().contains(commit_id)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user