forked from mirrors/jj
repo: inline merge_single_ref() from view
MutableRepo handles merging of the other kind of refs internally, and the merge function is short enough to inline. I also removed early returns since most callers provide non-identical ref targets, and merge_ref_targets() should be cheap if the inputs can be trivially merged.
This commit is contained in:
parent
5543f7a11c
commit
ffe7e5f142
2 changed files with 7 additions and 30 deletions
|
@ -1156,12 +1156,7 @@ impl MutableRepo {
|
|||
.map(|(name, diff)| (RefName::GitRef(name.to_owned()), diff)),
|
||||
);
|
||||
for (ref_name, (base_target, other_target)) in changed_refs {
|
||||
self.view.get_mut().merge_single_ref(
|
||||
self.index.as_index(),
|
||||
&ref_name,
|
||||
base_target,
|
||||
other_target,
|
||||
);
|
||||
self.merge_single_ref(&ref_name, base_target, other_target);
|
||||
}
|
||||
|
||||
let changed_remote_branches =
|
||||
|
@ -1233,12 +1228,11 @@ impl MutableRepo {
|
|||
base_target: &RefTarget,
|
||||
other_target: &RefTarget,
|
||||
) {
|
||||
self.view.get_mut().merge_single_ref(
|
||||
self.index.as_index(),
|
||||
ref_name,
|
||||
base_target,
|
||||
other_target,
|
||||
);
|
||||
let view = self.view.get_mut();
|
||||
let index = self.index.as_index();
|
||||
let self_target = view.get_ref(ref_name);
|
||||
let new_target = merge_ref_targets(index, self_target, base_target, other_target);
|
||||
view.set_ref_target(ref_name, new_target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,10 @@ use std::fmt;
|
|||
use itertools::Itertools;
|
||||
|
||||
use crate::backend::CommitId;
|
||||
use crate::index::Index;
|
||||
use crate::op_store::{
|
||||
BranchTarget, RefTarget, RefTargetOptionExt as _, RemoteRef, RemoteRefState, WorkspaceId,
|
||||
};
|
||||
use crate::refs::{merge_ref_targets, TrackingRefPair};
|
||||
use crate::refs::TrackingRefPair;
|
||||
use crate::str_util::StringPattern;
|
||||
use crate::{op_store, refs};
|
||||
|
||||
|
@ -367,20 +366,4 @@ impl View {
|
|||
pub fn store_view_mut(&mut self) -> &mut op_store::View {
|
||||
&mut self.data
|
||||
}
|
||||
|
||||
pub fn merge_single_ref(
|
||||
&mut self,
|
||||
index: &dyn Index,
|
||||
ref_name: &RefName,
|
||||
base_target: &RefTarget,
|
||||
other_target: &RefTarget,
|
||||
) {
|
||||
if base_target != other_target {
|
||||
let self_target = self.get_ref(ref_name);
|
||||
let new_target = merge_ref_targets(index, self_target, base_target, other_target);
|
||||
if new_target != *self_target {
|
||||
self.set_ref_target(ref_name, new_target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue