From 82c683bf63a81e4b279a513cc7bd0ef4e10daf1d Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 13 Mar 2021 23:31:00 -0800 Subject: [PATCH] Transaction: rename as_repo_mut() to mut_repo() I think the `as_` prefix of `as_repo_mut()` makes it sound like it returns a view of the `Transaction`, but the `MutableRepo` is actually a part of it. Also, the convention seems to be to put the `mut_` in the name first if the function returns a name with a matching name (like `MutableRepo` does). --- lib/src/evolution.rs | 6 +++--- lib/src/transaction.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/evolution.rs b/lib/src/evolution.rs index a3063e965..8ebc28aeb 100644 --- a/lib/src/evolution.rs +++ b/lib/src/evolution.rs @@ -484,7 +484,7 @@ pub fn evolve( // Resolving divergence can creates new orphans but not vice versa, so resolve // divergence first. let divergent_changes: Vec<_> = tx - .as_repo_mut() + .mut_repo() .evolution() .state .non_obsoletes_by_changeid @@ -503,7 +503,7 @@ pub fn evolve( // Dom't reuse the state from above, since the divergence-resolution may have // created new orphans, or resolved existing orphans. let orphans: HashSet = tx - .as_repo_mut() + .mut_repo() .evolution() .state .orphan_commits @@ -533,7 +533,7 @@ pub fn evolve( let old_parents = orphan.parents(); let mut new_parents = vec![]; let mut ambiguous_new_parents = false; - let evolution = tx.as_repo_mut().evolution(); + let evolution = tx.mut_repo().evolution(); for old_parent in &old_parents { let new_parent_candidates = evolution.new_parent(old_parent.id()); if new_parent_candidates.len() > 1 { diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index 810792a52..9c328539b 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -56,7 +56,7 @@ impl<'r> Transaction<'r> { self.repo.as_ref().unwrap().as_repo_ref() } - pub fn as_repo_mut(&mut self) -> &mut MutableRepo<'r> { + pub fn mut_repo(&mut self) -> &mut MutableRepo<'r> { Arc::get_mut(self.repo.as_mut().unwrap()).unwrap() }