forked from mirrors/jj
working_copy: remove .clone() from TreeState proxy methods
Let the caller .clone() as needed.
This commit is contained in:
parent
786e6211d8
commit
1800354465
3 changed files with 12 additions and 12 deletions
|
@ -1071,16 +1071,16 @@ impl WorkingCopy {
|
|||
self.tree_state.get_mut().unwrap()
|
||||
}
|
||||
|
||||
pub fn current_tree_id(&self) -> TreeId {
|
||||
self.tree_state().current_tree_id().clone()
|
||||
pub fn current_tree_id(&self) -> &TreeId {
|
||||
self.tree_state().current_tree_id()
|
||||
}
|
||||
|
||||
pub fn file_states(&self) -> BTreeMap<RepoPath, FileState> {
|
||||
self.tree_state().file_states().clone()
|
||||
pub fn file_states(&self) -> &BTreeMap<RepoPath, FileState> {
|
||||
self.tree_state().file_states()
|
||||
}
|
||||
|
||||
pub fn sparse_patterns(&self) -> Vec<RepoPath> {
|
||||
self.tree_state().sparse_patterns().clone()
|
||||
pub fn sparse_patterns(&self) -> &[RepoPath] {
|
||||
self.tree_state().sparse_patterns()
|
||||
}
|
||||
|
||||
fn save(&mut self) {
|
||||
|
@ -1100,7 +1100,7 @@ impl WorkingCopy {
|
|||
// has changed.
|
||||
self.tree_state.take();
|
||||
let old_operation_id = self.operation_id();
|
||||
let old_tree_id = self.current_tree_id();
|
||||
let old_tree_id = self.current_tree_id().clone();
|
||||
|
||||
LockedWorkingCopy {
|
||||
wc: self,
|
||||
|
@ -1180,7 +1180,7 @@ impl LockedWorkingCopy<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sparse_patterns(&self) -> Vec<RepoPath> {
|
||||
pub fn sparse_patterns(&self) -> &[RepoPath] {
|
||||
self.wc.sparse_patterns()
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1199,7 @@ impl LockedWorkingCopy<'_> {
|
|||
}
|
||||
|
||||
pub fn finish(mut self, operation_id: OperationId) {
|
||||
assert!(self.tree_state_dirty || self.old_tree_id == self.wc.current_tree_id());
|
||||
assert!(self.tree_state_dirty || &self.old_tree_id == self.wc.current_tree_id());
|
||||
if self.tree_state_dirty {
|
||||
self.wc.tree_state_mut().save();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ fn test_concurrent_checkout(use_git: bool) {
|
|||
// Check that the tree2 is still checked out on disk.
|
||||
let workspace3 =
|
||||
Workspace::load(&settings, &workspace1_root, &BackendFactories::default()).unwrap();
|
||||
assert_eq!(workspace3.working_copy().current_tree_id(), tree_id2);
|
||||
assert_eq!(workspace3.working_copy().current_tree_id(), &tree_id2);
|
||||
}
|
||||
|
||||
#[test_case(false ; "local backend")]
|
||||
|
|
|
@ -3969,7 +3969,7 @@ fn cmd_sparse(ui: &mut Ui, command: &CommandHelper, args: &SparseArgs) -> Result
|
|||
if args.list {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
for path in workspace_command.working_copy().sparse_patterns() {
|
||||
let ui_path = workspace_command.format_file_path(&path);
|
||||
let ui_path = workspace_command.format_file_path(path);
|
||||
writeln!(ui, "{}", ui_path)?;
|
||||
}
|
||||
} else {
|
||||
|
@ -3982,7 +3982,7 @@ fn cmd_sparse(ui: &mut Ui, command: &CommandHelper, args: &SparseArgs) -> Result
|
|||
new_patterns.insert(RepoPath::root());
|
||||
} else {
|
||||
if !args.clear {
|
||||
new_patterns.extend(locked_wc.sparse_patterns());
|
||||
new_patterns.extend(locked_wc.sparse_patterns().iter().cloned());
|
||||
let paths_to_remove = repo_paths_from_values(ui, &workspace_root, &args.remove)?;
|
||||
for path in paths_to_remove {
|
||||
new_patterns.remove(&path);
|
||||
|
|
Loading…
Reference in a new issue