mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
tree: leverage trivial_merge()
for file executable bit
This commit is contained in:
parent
f838d083d3
commit
97c64d8071
1 changed files with 9 additions and 18 deletions
|
@ -667,18 +667,14 @@ fn try_resolve_file_conflict(
|
||||||
// early so we don't waste time reading file contents if we can't merge them
|
// early so we don't waste time reading file contents if we can't merge them
|
||||||
// anyway. At the same time we determine whether the resulting file should
|
// anyway. At the same time we determine whether the resulting file should
|
||||||
// be executable.
|
// be executable.
|
||||||
let mut exec_delta = 0;
|
let mut executable_removes = vec![];
|
||||||
let mut regular_delta = 0;
|
let mut executable_adds = vec![];
|
||||||
let mut removed_file_ids = vec![];
|
let mut removed_file_ids = vec![];
|
||||||
let mut added_file_ids = vec![];
|
let mut added_file_ids = vec![];
|
||||||
for term in &conflict.removes {
|
for term in conflict.removes.iter() {
|
||||||
match &term.value {
|
match &term.value {
|
||||||
TreeValue::File { id, executable } => {
|
TreeValue::File { id, executable } => {
|
||||||
if *executable {
|
executable_removes.push(*executable);
|
||||||
exec_delta -= 1;
|
|
||||||
} else {
|
|
||||||
regular_delta -= 1;
|
|
||||||
}
|
|
||||||
removed_file_ids.push(id.clone());
|
removed_file_ids.push(id.clone());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -686,14 +682,10 @@ fn try_resolve_file_conflict(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for term in &conflict.adds {
|
for term in conflict.adds.iter() {
|
||||||
match &term.value {
|
match &term.value {
|
||||||
TreeValue::File { id, executable } => {
|
TreeValue::File { id, executable } => {
|
||||||
if *executable {
|
executable_adds.push(*executable);
|
||||||
exec_delta += 1;
|
|
||||||
} else {
|
|
||||||
regular_delta += 1;
|
|
||||||
}
|
|
||||||
added_file_ids.push(id.clone());
|
added_file_ids.push(id.clone());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -701,10 +693,9 @@ fn try_resolve_file_conflict(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let executable = if exec_delta > 0 && regular_delta <= 0 {
|
let executable = if let Some(executable) = trivial_merge(&executable_removes, &executable_adds)
|
||||||
true
|
{
|
||||||
} else if regular_delta > 0 && exec_delta <= 0 {
|
executable
|
||||||
false
|
|
||||||
} else {
|
} else {
|
||||||
// We're unable to determine whether the result should be executable
|
// We're unable to determine whether the result should be executable
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
|
Loading…
Reference in a new issue