mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-07 08:22:50 +00:00
merge-tools builtin: add regression test for directory replaced by file
This is a manual regression test for issue #5189. When this change is replaced onto `v0.28.2`, the test produces a panic, as described in the issue. As of #6411, the panic no longer happens. However, the test still fails and rightfully so: When following the reproduction and not selecting any change in `jj split`, the split-off (first) commit will still record the deletion of `folder/.keep` but not the creation of the file `folder`.
This commit is contained in:
parent
05fa4bc0a3
commit
7ff6741e14
@ -640,6 +640,7 @@ mod tests {
|
|||||||
use jj_lib::merge::MergedTreeValue;
|
use jj_lib::merge::MergedTreeValue;
|
||||||
use jj_lib::repo::Repo as _;
|
use jj_lib::repo::Repo as _;
|
||||||
use testutils::repo_path;
|
use testutils::repo_path;
|
||||||
|
use testutils::repo_path_component;
|
||||||
use testutils::TestRepo;
|
use testutils::TestRepo;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -1259,6 +1260,75 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_edit_diff_builtin_replace_directory_with_file() {
|
||||||
|
let test_repo = TestRepo::init();
|
||||||
|
let store = test_repo.repo.store();
|
||||||
|
|
||||||
|
let folder_path = repo_path("folder");
|
||||||
|
let file_in_folder_path = folder_path.join(repo_path_component("file_in_folder"));
|
||||||
|
let left_tree = testutils::create_tree(&test_repo.repo, &[(&file_in_folder_path, "")]);
|
||||||
|
let right_tree = testutils::create_tree(&test_repo.repo, &[(folder_path, "")]);
|
||||||
|
|
||||||
|
let (changed_files, files) = make_diff(store, &left_tree, &right_tree);
|
||||||
|
insta::assert_debug_snapshot!(changed_files, @r#"
|
||||||
|
[
|
||||||
|
"folder/file_in_folder",
|
||||||
|
"folder",
|
||||||
|
]
|
||||||
|
"#);
|
||||||
|
insta::assert_debug_snapshot!(files, @r#"
|
||||||
|
[
|
||||||
|
File {
|
||||||
|
old_path: None,
|
||||||
|
path: "folder/file_in_folder",
|
||||||
|
file_mode: Unix(
|
||||||
|
33188,
|
||||||
|
),
|
||||||
|
sections: [
|
||||||
|
FileMode {
|
||||||
|
is_checked: false,
|
||||||
|
mode: Absent,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
File {
|
||||||
|
old_path: None,
|
||||||
|
path: "folder",
|
||||||
|
file_mode: Absent,
|
||||||
|
sections: [
|
||||||
|
FileMode {
|
||||||
|
is_checked: false,
|
||||||
|
mode: Unix(
|
||||||
|
33188,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
"#);
|
||||||
|
let no_changes_tree_id = apply_diff(store, &left_tree, &right_tree, &changed_files, &files);
|
||||||
|
let no_changes_tree = store.get_root_tree(&no_changes_tree_id).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
no_changes_tree.id(),
|
||||||
|
left_tree.id(),
|
||||||
|
"no-changes tree was different",
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut files = files;
|
||||||
|
for file in &mut files {
|
||||||
|
file.toggle_all();
|
||||||
|
}
|
||||||
|
let all_changes_tree_id =
|
||||||
|
apply_diff(store, &left_tree, &right_tree, &changed_files, &files);
|
||||||
|
let all_changes_tree = store.get_root_tree(&all_changes_tree_id).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
all_changes_tree.id(),
|
||||||
|
right_tree.id(),
|
||||||
|
"all-changes tree was different",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_make_merge_sections() {
|
fn test_make_merge_sections() {
|
||||||
let test_repo = TestRepo::init();
|
let test_repo = TestRepo::init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user