ok/jj
1
0
Fork 0
forked from mirrors/jj

working_copy: remove file state for deleted files in only one place

We currently remove the file state for deleted files after walking the
working copy and noticing that the file is not there. However, in the
case of files that have been replaced by special files like Unix
sockets, we delete the file state inside the loop. Let's simplify a
tiny bit by not doing that.
This commit is contained in:
Martin von Zweigbergk 2023-07-31 13:52:09 -07:00 committed by Martin von Zweigbergk
parent 3f23508b5f
commit 035d4bbbae

View file

@ -698,9 +698,7 @@ impl TreeState {
disk_dir: entry.path(), disk_dir: entry.path(),
git_ignore: git_ignore.clone(), git_ignore: git_ignore.clone(),
}); });
} else { } else if matcher.matches(&sub_path) {
deleted_files.remove(&sub_path);
if matcher.matches(&sub_path) {
if let Some(progress) = progress { if let Some(progress) = progress {
progress(&sub_path); progress(&sub_path);
} }
@ -721,6 +719,7 @@ impl TreeState {
err, err,
})?; })?;
if let Some(new_file_state) = file_state(&metadata) { if let Some(new_file_state) = file_state(&metadata) {
deleted_files.remove(&sub_path);
let update = self.get_updated_file_state( let update = self.get_updated_file_state(
&sub_path, &sub_path,
entry.path(), entry.path(),
@ -733,15 +732,10 @@ impl TreeState {
self.file_states.insert(sub_path, new_file_state); self.file_states.insert(sub_path, new_file_state);
} }
UpdatedFileState::Changed(tree_value) => { UpdatedFileState::Changed(tree_value) => {
self.file_states self.file_states.insert(sub_path.clone(), new_file_state);
.insert(sub_path.clone(), new_file_state);
tree_builder.set(sub_path, tree_value); tree_builder.set(sub_path, tree_value);
} }
} }
} else {
self.file_states.remove(&sub_path);
tree_builder.remove(sub_path);
}
} }
} }
} }