mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-26 06:01:48 +00:00
working_copy: combine blocks for updating added/modified paths
There's a lot of duplication between the blocks of code for updating modified and added paths. This commit combines them.
This commit is contained in:
parent
01a6578ada
commit
1571541214
1 changed files with 9 additions and 22 deletions
|
@ -1241,7 +1241,10 @@ impl TreeState {
|
|||
}
|
||||
stats.updated_files += 1;
|
||||
}
|
||||
(None, Some(after)) => {
|
||||
(before, Some(after)) => {
|
||||
if before.is_some() {
|
||||
fs::remove_file(&disk_path).ok();
|
||||
}
|
||||
let file_state = match after {
|
||||
TreeValue::File { id, executable } => {
|
||||
self.write_file(&disk_path, &path, &id, executable)?
|
||||
|
@ -1257,27 +1260,11 @@ impl TreeState {
|
|||
}
|
||||
};
|
||||
self.file_states.insert(path, file_state);
|
||||
stats.added_files += 1;
|
||||
}
|
||||
(Some(_before), Some(after)) => {
|
||||
fs::remove_file(&disk_path).ok();
|
||||
let file_state = match after {
|
||||
TreeValue::File { id, executable } => {
|
||||
self.write_file(&disk_path, &path, &id, executable)?
|
||||
}
|
||||
TreeValue::Symlink(id) => self.write_symlink(&disk_path, &path, &id)?,
|
||||
TreeValue::Conflict(id) => self.write_conflict(&disk_path, &path, &id)?,
|
||||
TreeValue::GitSubmodule(_id) => {
|
||||
println!("ignoring git submodule at {path:?}");
|
||||
FileState::for_gitsubmodule()
|
||||
}
|
||||
TreeValue::Tree(_id) => {
|
||||
panic!("unexpected tree entry in diff at {path:?}");
|
||||
}
|
||||
};
|
||||
|
||||
self.file_states.insert(path, file_state);
|
||||
stats.updated_files += 1;
|
||||
if before.is_none() {
|
||||
stats.added_files += 1;
|
||||
} else {
|
||||
stats.updated_files += 1;
|
||||
}
|
||||
}
|
||||
(None, None) => {
|
||||
unreachable!()
|
||||
|
|
Loading…
Reference in a new issue