mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 15:16:35 +00:00
diff_edit: do not make directories readonly
Otherwise directories containing files cannot be removed. I think making files readonly is enough to tell user that the left side cannot be edited, but I haven't tested that with Meld. If that's not enough, we'll probably need to undo set_readonly_recursively() at exit.
This commit is contained in:
parent
e4a39137c9
commit
3b60769874
1 changed files with 7 additions and 3 deletions
|
@ -82,14 +82,18 @@ fn check_out(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_readonly_recursively(path: &Path) -> Result<(), std::io::Error> {
|
fn set_readonly_recursively(path: &Path) -> Result<(), std::io::Error> {
|
||||||
|
// Directory permission is unchanged since files under readonly directory cannot
|
||||||
|
// be removed.
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
for entry in path.read_dir()? {
|
for entry in path.read_dir()? {
|
||||||
set_readonly_recursively(&entry?.path())?;
|
set_readonly_recursively(&entry?.path())?;
|
||||||
}
|
}
|
||||||
}
|
Ok(())
|
||||||
|
} else {
|
||||||
let mut perms = std::fs::metadata(path)?.permissions();
|
let mut perms = std::fs::metadata(path)?.permissions();
|
||||||
perms.set_readonly(true);
|
perms.set_readonly(true);
|
||||||
std::fs::set_permissions(path, perms)
|
std::fs::set_permissions(path, perms)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit_diff(
|
pub fn edit_diff(
|
||||||
|
|
Loading…
Reference in a new issue