mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-20 11:25:34 +00:00
merge: add helper function to match Option<impl Borrow<TreeValue>>
More callers will be added by the next commit.
This commit is contained in:
parent
accd1e337a
commit
8268af9b4f
1 changed files with 7 additions and 8 deletions
|
@ -617,15 +617,10 @@ where
|
||||||
store: &Arc<Store>,
|
store: &Arc<Store>,
|
||||||
dir: &RepoPath,
|
dir: &RepoPath,
|
||||||
) -> BackendResult<Option<Merge<Tree>>> {
|
) -> BackendResult<Option<Merge<Tree>>> {
|
||||||
let tree_id_merge = self.maybe_map(|term| match term {
|
let tree_id_merge = self.maybe_map(|term| match borrow_tree_value(term.as_ref()) {
|
||||||
None => Some(None),
|
None => Some(None),
|
||||||
Some(value) => {
|
Some(TreeValue::Tree(id)) => Some(Some(id)),
|
||||||
if let TreeValue::Tree(id) = value.borrow() {
|
Some(_) => None,
|
||||||
Some(Some(id))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if let Some(tree_id_merge) = tree_id_merge {
|
if let Some(tree_id_merge) = tree_id_merge {
|
||||||
let get_tree = |id: &Option<&TreeId>| -> BackendResult<Tree> {
|
let get_tree = |id: &Option<&TreeId>| -> BackendResult<Tree> {
|
||||||
|
@ -642,6 +637,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn borrow_tree_value<T: Borrow<TreeValue> + ?Sized>(term: Option<&T>) -> Option<&TreeValue> {
|
||||||
|
term.map(|value| value.borrow())
|
||||||
|
}
|
||||||
|
|
||||||
fn describe_conflict_term(value: &TreeValue) -> String {
|
fn describe_conflict_term(value: &TreeValue) -> String {
|
||||||
match value {
|
match value {
|
||||||
TreeValue::File {
|
TreeValue::File {
|
||||||
|
|
Loading…
Reference in a new issue