mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-31 00:12:06 +00:00
cli: don't materialize conflicts when editing diffs
The diff-editing code shares the `TreeState` functionality with the working-copy code. That means we can now let the user edit conflicts without materializing them first. So now the user can do e.g. `jj edit -r <some commit>` and resolve only some of the conflicts.
This commit is contained in:
parent
e901a4e66b
commit
99e5a28d17
1 changed files with 3 additions and 24 deletions
|
@ -18,12 +18,11 @@ use std::path::{Path, PathBuf};
|
|||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use jujutsu_lib::backend::{BackendError, TreeId, TreeValue};
|
||||
use jujutsu_lib::backend::{BackendError, TreeId};
|
||||
use jujutsu_lib::matchers::EverythingMatcher;
|
||||
use jujutsu_lib::repo_path::RepoPath;
|
||||
use jujutsu_lib::store::Store;
|
||||
use jujutsu_lib::tree::{merge_trees, Tree};
|
||||
use jujutsu_lib::tree_builder::TreeBuilder;
|
||||
use jujutsu_lib::working_copy::{CheckoutError, TreeState};
|
||||
use tempfile::tempdir;
|
||||
use thiserror::Error;
|
||||
|
@ -52,26 +51,6 @@ impl From<BackendError> for DiffEditError {
|
|||
}
|
||||
}
|
||||
|
||||
fn add_to_tree(
|
||||
store: &Store,
|
||||
tree_builder: &mut TreeBuilder,
|
||||
repo_path: &RepoPath,
|
||||
value: &TreeValue,
|
||||
) -> Result<(), BackendError> {
|
||||
match value {
|
||||
TreeValue::Conflict(conflict_id) => {
|
||||
let conflict = store.read_conflict(conflict_id)?;
|
||||
let materialized_value =
|
||||
jujutsu_lib::conflicts::conflict_to_materialized_value(store, repo_path, &conflict);
|
||||
tree_builder.set(repo_path.clone(), materialized_value);
|
||||
}
|
||||
_ => {
|
||||
tree_builder.set(repo_path.clone(), (*value).clone());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_out(
|
||||
store: Arc<Store>,
|
||||
wc_dir: PathBuf,
|
||||
|
@ -110,10 +89,10 @@ pub fn edit_diff(
|
|||
for (file_path, diff) in left_tree.diff(right_tree, &EverythingMatcher) {
|
||||
let (left_value, right_value) = diff.as_options();
|
||||
if let Some(value) = left_value {
|
||||
add_to_tree(store, &mut left_tree_builder, &file_path, value).unwrap();
|
||||
left_tree_builder.set(file_path.clone(), value.clone());
|
||||
}
|
||||
if let Some(value) = right_value {
|
||||
add_to_tree(store, &mut right_tree_builder, &file_path, value).unwrap();
|
||||
right_tree_builder.set(file_path.clone(), value.clone());
|
||||
}
|
||||
}
|
||||
let left_partial_tree_id = left_tree_builder.write_tree();
|
||||
|
|
Loading…
Reference in a new issue