mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-09 05:58:55 +00:00
cli: construct "op restore"-d view by cloning each field
This will force us to think about whether new field belongs to "repo" or "remote".
This commit is contained in:
parent
b7c7b19eb8
commit
af70818128
1 changed files with 16 additions and 17 deletions
|
@ -161,27 +161,26 @@ fn view_with_desired_portions_restored(
|
||||||
current_view: &jj_lib::op_store::View,
|
current_view: &jj_lib::op_store::View,
|
||||||
what: &[UndoWhatToRestore],
|
what: &[UndoWhatToRestore],
|
||||||
) -> jj_lib::op_store::View {
|
) -> jj_lib::op_store::View {
|
||||||
let mut new_view = if what.contains(&UndoWhatToRestore::Repo) {
|
let repo_source = if what.contains(&UndoWhatToRestore::Repo) {
|
||||||
view_being_restored.clone()
|
view_being_restored
|
||||||
} else {
|
} else {
|
||||||
current_view.clone()
|
current_view
|
||||||
};
|
};
|
||||||
|
let remote_source = if what.contains(&UndoWhatToRestore::RemoteTracking) {
|
||||||
new_view.git_refs = current_view.git_refs.clone();
|
view_being_restored
|
||||||
new_view.git_head = current_view.git_head.clone();
|
|
||||||
|
|
||||||
if what.contains(&UndoWhatToRestore::RemoteTracking) == what.contains(&UndoWhatToRestore::Repo)
|
|
||||||
{
|
|
||||||
// new_view already contains the correct branches; we can short-curcuit
|
|
||||||
return new_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
if what.contains(&UndoWhatToRestore::RemoteTracking) {
|
|
||||||
new_view.remote_views = view_being_restored.remote_views.clone();
|
|
||||||
} else {
|
} else {
|
||||||
new_view.remote_views = current_view.remote_views.clone();
|
current_view
|
||||||
|
};
|
||||||
|
jj_lib::op_store::View {
|
||||||
|
head_ids: repo_source.head_ids.clone(),
|
||||||
|
public_head_ids: repo_source.public_head_ids.clone(),
|
||||||
|
local_branches: repo_source.local_branches.clone(),
|
||||||
|
tags: repo_source.tags.clone(),
|
||||||
|
remote_views: remote_source.remote_views.clone(),
|
||||||
|
git_refs: current_view.git_refs.clone(),
|
||||||
|
git_head: current_view.git_head.clone(),
|
||||||
|
wc_commit_ids: repo_source.wc_commit_ids.clone(),
|
||||||
}
|
}
|
||||||
new_view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_op_undo(
|
pub fn cmd_op_undo(
|
||||||
|
|
Loading…
Reference in a new issue