mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +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>,
|
||||
dir: &RepoPath,
|
||||
) -> 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),
|
||||
Some(value) => {
|
||||
if let TreeValue::Tree(id) = value.borrow() {
|
||||
Some(Some(id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(TreeValue::Tree(id)) => Some(Some(id)),
|
||||
Some(_) => None,
|
||||
});
|
||||
if let Some(tree_id_merge) = tree_id_merge {
|
||||
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 {
|
||||
match value {
|
||||
TreeValue::File {
|
||||
|
|
Loading…
Reference in a new issue