mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-08 05:39:20 +00:00
working_copy: extract inner action of update() loop as closure
It serves as a try_block where I'm going to add EEXIST handling.
This commit is contained in:
parent
7072cfe5b1
commit
d8a313cdd4
1 changed files with 8 additions and 4 deletions
|
@ -794,8 +794,7 @@ impl TreeState {
|
||||||
added_files: 0,
|
added_files: 0,
|
||||||
removed_files: 0,
|
removed_files: 0,
|
||||||
};
|
};
|
||||||
|
let mut apply_diff = |path: RepoPath, diff: Diff<TreeValue>| -> Result<(), CheckoutError> {
|
||||||
for (path, diff) in old_tree.diff(new_tree, matcher) {
|
|
||||||
let disk_path = path.to_fs_path(&self.working_copy_path);
|
let disk_path = path.to_fs_path(&self.working_copy_path);
|
||||||
|
|
||||||
// TODO: Check that the file has not changed before overwriting/removing it.
|
// TODO: Check that the file has not changed before overwriting/removing it.
|
||||||
|
@ -821,7 +820,7 @@ impl TreeState {
|
||||||
TreeValue::Conflict(id) => self.write_conflict(&disk_path, &path, &id)?,
|
TreeValue::Conflict(id) => self.write_conflict(&disk_path, &path, &id)?,
|
||||||
TreeValue::GitSubmodule(_id) => {
|
TreeValue::GitSubmodule(_id) => {
|
||||||
println!("ignoring git submodule at {:?}", path);
|
println!("ignoring git submodule at {:?}", path);
|
||||||
continue;
|
return Ok(());
|
||||||
}
|
}
|
||||||
TreeValue::Tree(_id) => {
|
TreeValue::Tree(_id) => {
|
||||||
panic!("unexpected tree entry in diff at {:?}", path);
|
panic!("unexpected tree entry in diff at {:?}", path);
|
||||||
|
@ -859,7 +858,7 @@ impl TreeState {
|
||||||
(_, TreeValue::GitSubmodule(_id)) => {
|
(_, TreeValue::GitSubmodule(_id)) => {
|
||||||
println!("ignoring git submodule at {:?}", path);
|
println!("ignoring git submodule at {:?}", path);
|
||||||
self.file_states.remove(&path);
|
self.file_states.remove(&path);
|
||||||
continue;
|
return Ok(());
|
||||||
}
|
}
|
||||||
(_, TreeValue::Tree(_id)) => {
|
(_, TreeValue::Tree(_id)) => {
|
||||||
panic!("unexpected tree entry in diff at {:?}", path);
|
panic!("unexpected tree entry in diff at {:?}", path);
|
||||||
|
@ -870,6 +869,11 @@ impl TreeState {
|
||||||
stats.updated_files += 1;
|
stats.updated_files += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
|
};
|
||||||
|
|
||||||
|
for (path, diff) in old_tree.diff(new_tree, matcher) {
|
||||||
|
apply_diff(path, diff)?;
|
||||||
}
|
}
|
||||||
Ok(stats)
|
Ok(stats)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue