Skip to content

Commit

Permalink
copy-tracking: add source field to TreeDiffEntry
Browse files Browse the repository at this point in the history
- add the field and make it compile, but don't use it yet
  • Loading branch information
fowles committed Aug 11, 2024
1 parent 8e84c60 commit e123eb2
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/src/commands/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub(crate) fn cmd_fix(
let mut diff_stream = parent_tree.diff_stream(&tree, &matcher);
async {
while let Some(TreeDiffEntry {
source: _, // TODO handle copy tracking
target: repo_path,
value: diff,
}) = diff_stream.next().await
Expand Down
2 changes: 2 additions & 0 deletions cli/src/diff_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ pub fn show_diff_summary(
) -> io::Result<()> {
async {
while let Some(TreeDiffEntry {
source: _, // TODO handle copy tracking
target: repo_path,
value: diff,
}) = tree_diff.next().await
Expand Down Expand Up @@ -1246,6 +1247,7 @@ pub fn show_types(
) -> io::Result<()> {
async {
while let Some(TreeDiffEntry {
source: _, // TODO handle copy tracking
target: repo_path,
value: diff,
}) = tree_diff.next().await
Expand Down
1 change: 1 addition & 0 deletions cli/src/merge_tools/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ pub fn edit_diff_builtin(
.diff_stream(right_tree, matcher)
.map(
|TreeDiffEntry {
source: _, // TODO handle copy tracking
target: path,
value: diff,
}| diff.map(|_| path),
Expand Down
1 change: 1 addition & 0 deletions lib/src/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ pub fn materialized_diff_stream<'a>(
tree_diff
.map(
|TreeDiffEntry {
source: _, // TODO handle copy tracking
target: path,
value: diff,
}| async {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/local_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ impl TreeState {
.diff_stream(new_tree, matcher)
.map(
|TreeDiffEntry {
source: _, // TODO handle copy tracking
target: path,
value: diff,
}| async {
Expand Down Expand Up @@ -1454,6 +1455,7 @@ impl TreeState {
let mut deleted_files = HashSet::new();
let mut diff_stream = old_tree.diff_stream(new_tree, matcher.as_ref());
while let Some(TreeDiffEntry {
source: _, // TODO handle copy tracking
target: path,
value: diff,
}) = diff_stream.next().await
Expand Down
12 changes: 11 additions & 1 deletion lib/src/merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ impl MergedTree {

/// A single entry in a tree diff.
pub struct TreeDiffEntry {
// pub source: RepoPathBuf,
/// The source path.
pub source: RepoPathBuf,
/// The target path.
pub target: RepoPathBuf,
/// The resolved tree values if available.
Expand Down Expand Up @@ -712,6 +713,7 @@ impl Iterator for TreeDiffIterator<'_> {
TreeDiffItem::File(..) => {
if let TreeDiffItem::File(path, before, after) = self.stack.pop().unwrap() {
return Some(TreeDiffEntry {
source: path.clone(),
target: path,
value: Ok((before, after)),
});
Expand All @@ -731,12 +733,14 @@ impl Iterator for TreeDiffIterator<'_> {
(Ok(before_tree), Ok(after_tree)) => (before_tree, after_tree),
(Err(before_err), _) => {
return Some(TreeDiffEntry {
source: path.clone(),
target: path,
value: Err(before_err),
})
}
(_, Err(after_err)) => {
return Some(TreeDiffEntry {
source: path.clone(),
target: path,
value: Err(after_err),
})
Expand All @@ -752,6 +756,7 @@ impl Iterator for TreeDiffIterator<'_> {
if !tree_before && tree_after {
if before.is_present() {
return Some(TreeDiffEntry {
source: path.clone(),
target: path,
value: Ok((before, Merge::absent())),
});
Expand All @@ -765,6 +770,7 @@ impl Iterator for TreeDiffIterator<'_> {
}
} else if !tree_before && !tree_after {
return Some(TreeDiffEntry {
source: path.clone(),
target: path,
value: Ok((before, after)),
});
Expand Down Expand Up @@ -999,10 +1005,12 @@ impl Stream for TreeDiffStreamImpl<'_> {
let (key, result) = entry.remove_entry();
Poll::Ready(Some(match result {
Err(err) => TreeDiffEntry {
source: key.path.clone(),
target: key.path,
value: Err(err),
},
Ok((before, after)) => TreeDiffEntry {
source: key.path.clone(),
target: key.path,
value: Ok((before, after)),
},
Expand All @@ -1013,10 +1021,12 @@ impl Stream for TreeDiffStreamImpl<'_> {
let (key, result) = entry.remove_entry();
Poll::Ready(Some(match result {
Err(err) => TreeDiffEntry {
source: key.path.clone(),
target: key.path,
value: Err(err),
},
Ok((before, after)) => TreeDiffEntry {
source: key.path.clone(),
target: key.path,
value: Ok((before, after)),
},
Expand Down
1 change: 1 addition & 0 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn restore_tree(
async {
let mut diff_stream = source.diff_stream(destination, matcher);
while let Some(TreeDiffEntry {
source: _, // TODO handle copy tracking
target: repo_path,
value: diff,
}) = diff_stream.next().await
Expand Down

0 comments on commit e123eb2

Please sign in to comment.