Skip to content

Commit

Permalink
working_copy: remove last use of current_tree()
Browse files Browse the repository at this point in the history
We were using `current_tree()` only for an assertion where we were
walking its entries. Now that `MergedTree` supports that, we can
replace `current_tree()` by `current_merged_tree()`.

There's more work needed before the working copy can fully work with
tree-level conflicts. We still need to be able to store multiple tree
ids in the `tree_state` file, and we need to be able to create
multiple trees instead of writing conflict objects to the backend.
  • Loading branch information
martinvonz committed Aug 25, 2023
1 parent 871bc53 commit e3aa79d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/src/working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,7 @@ impl TreeState {
Ok(())
}

fn current_tree(&self) -> Result<Tree, BackendError> {
self.store.get_tree(&RepoPath::root(), &self.tree_id)
}

fn current_merged_tree(&self) -> Result<MergedTree, BackendError> {
fn current_tree(&self) -> Result<MergedTree, BackendError> {
let tree = self.store.get_tree(&RepoPath::root(), &self.tree_id)?;
Ok(MergedTree::legacy(tree))
}
Expand Down Expand Up @@ -659,7 +655,7 @@ impl TreeState {

trace_span!("traverse filesystem").in_scope(|| -> Result<(), SnapshotError> {
let matcher = IntersectionMatcher::new(sparse_matcher.as_ref(), fsmonitor_matcher);
let current_tree = self.current_merged_tree()?;
let current_tree = self.current_tree()?;
let directory_to_visit = DirectoryToVisit {
dir: RepoPath::root(),
disk_dir: self.working_copy_path.clone(),
Expand Down Expand Up @@ -1174,7 +1170,7 @@ impl TreeState {
}

pub fn check_out(&mut self, new_tree: &MergedTree) -> Result<CheckoutStats, CheckoutError> {
let old_tree = self.current_merged_tree().map_err(|err| match err {
let old_tree = self.current_tree().map_err(|err| match err {
err @ BackendError::ObjectNotFound { .. } => CheckoutError::SourceNotFound {
source: Box::new(err),
},
Expand All @@ -1189,7 +1185,7 @@ impl TreeState {
&mut self,
sparse_patterns: Vec<RepoPath>,
) -> Result<CheckoutStats, CheckoutError> {
let tree = self.current_merged_tree().map_err(|err| match err {
let tree = self.current_tree().map_err(|err| match err {
err @ BackendError::ObjectNotFound { .. } => CheckoutError::SourceNotFound {
source: Box::new(err),
},
Expand Down Expand Up @@ -1293,7 +1289,7 @@ impl TreeState {
}

pub fn reset(&mut self, new_tree: &MergedTree) -> Result<(), ResetError> {
let old_tree = self.current_merged_tree().map_err(|err| match err {
let old_tree = self.current_tree().map_err(|err| match err {
err @ BackendError::ObjectNotFound { .. } => ResetError::SourceNotFound {
source: Box::new(err),
},
Expand Down

0 comments on commit e3aa79d

Please sign in to comment.