core: carry PathUri through patch diffs

This commit is contained in:
Adam Perry
2026-07-10 01:59:36 +00:00
parent d92e7f98d3
commit b9c3499de3
6 changed files with 71 additions and 39 deletions
+9 -10
View File
@@ -223,7 +223,7 @@ impl Default for AppliedPatchDelta {
/// A committed file change, preserved in the order it was applied.
#[derive(Clone, Debug, PartialEq)]
pub struct AppliedPatchChange {
pub path: PathBuf,
pub path: PathUri,
pub change: AppliedPatchFileChange,
}
@@ -237,7 +237,7 @@ pub enum AppliedPatchFileChange {
content: String,
},
Update {
move_path: Option<PathBuf>,
move_path: Option<PathUri>,
old_content: String,
overwritten_move_content: Option<String>,
new_content: String,
@@ -387,7 +387,6 @@ async fn apply_hunks_to_files(
};
}
// TODO(anp): Carry PathUri through committed patch deltas and the turn diff tracker.
for hunk in hunks {
let affected_path = hunk.path().to_path_buf();
let path_uri = hunk.resolve_path(cwd)?;
@@ -406,7 +405,7 @@ async fn apply_hunks_to_files(
.await
);
delta.changes.push(AppliedPatchChange {
path: path_uri.to_path_buf(),
path: path_uri.clone(),
change: AppliedPatchFileChange::Add {
content: contents.clone(),
overwritten_content,
@@ -456,7 +455,7 @@ async fn apply_hunks_to_files(
}
if let Some(content) = deleted_content {
delta.changes.push(AppliedPatchChange {
path: path_uri.to_path_buf(),
path: path_uri.clone(),
change: AppliedPatchFileChange::Delete { content },
});
}
@@ -486,7 +485,7 @@ async fn apply_hunks_to_files(
);
let dest_write_change_index = delta.changes.len();
delta.changes.push(AppliedPatchChange {
path: dest_uri.to_path_buf(),
path: dest_uri.clone(),
change: AppliedPatchFileChange::Add {
content: new_contents.clone(),
overwritten_content: overwritten_move_content.clone(),
@@ -527,9 +526,9 @@ async fn apply_hunks_to_files(
return Err(error);
}
delta.changes[dest_write_change_index] = AppliedPatchChange {
path: path_uri.to_path_buf(),
path: path_uri.clone(),
change: AppliedPatchFileChange::Update {
move_path: Some(dest_uri.to_path_buf()),
move_path: Some(dest_uri),
old_content: original_contents,
overwritten_move_content,
new_content: new_contents,
@@ -546,7 +545,7 @@ async fn apply_hunks_to_files(
))
);
delta.changes.push(AppliedPatchChange {
path: path_uri.to_path_buf(),
path: path_uri.clone(),
change: AppliedPatchFileChange::Update {
move_path: None,
old_content: original_contents,
@@ -1156,7 +1155,7 @@ mod tests {
failure.delta(),
&AppliedPatchDelta::new(
vec![AppliedPatchChange {
path: dest.clone(),
path: PathUri::from_host_native_path(&dest).expect("absolute destination"),
change: AppliedPatchFileChange::Add {
content: "line2\n".to_string(),
overwritten_content: None,