Skip to content

Commit

Permalink
repo: inline merge_op_heads() (#111)
Browse files Browse the repository at this point in the history
The function is now pretty simple, and there's only one caller, so
let's inline it. It probably makes sense to move the code out of
`repo.rs` at some point.
  • Loading branch information
martinvonz committed Mar 26, 2022
1 parent 912ac94 commit f48b01a
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::rewrite::DescendantRebaser;
use crate::settings::{RepoSettings, UserSettings};
use crate::simple_op_store::SimpleOpStore;
use crate::store::Store;
use crate::transaction::{Transaction, UnpublishedOperation};
use crate::transaction::Transaction;
use crate::view::{RefName, View};
use crate::{backend, op_store};

Expand Down Expand Up @@ -310,10 +310,12 @@ pub struct UnresolvedHeadRepo {

impl UnresolvedHeadRepo {
pub fn resolve(self, user_settings: &UserSettings) -> Arc<ReadonlyRepo> {
let merged_repo = self
.repo_loader
.merge_op_heads(user_settings, self.op_heads)
.leave_unpublished();
let base_repo = self.repo_loader.load_at(&self.op_heads[0]);
let mut tx = base_repo.start_transaction("resolve concurrent operations");
for other_op_head in self.op_heads.into_iter().skip(1) {
tx.merge_operation(user_settings, other_op_head);
}
let merged_repo = tx.write().leave_unpublished();
self.locked_op_heads.finish(merged_repo.operation());
merged_repo
}
Expand Down Expand Up @@ -384,19 +386,6 @@ impl RepoLoader {
}
}

fn merge_op_heads(
&self,
user_settings: &UserSettings,
op_heads: Vec<Operation>,
) -> UnpublishedOperation {
let base_repo = self.load_at(&op_heads[0]);
let mut tx = base_repo.start_transaction("resolve concurrent operations");
for other_op_head in op_heads.into_iter().skip(1) {
tx.merge_operation(user_settings, other_op_head);
}
tx.write()
}

pub fn load_at(&self, op: &Operation) -> Arc<ReadonlyRepo> {
let view = View::new(op.view().take_store_view());
self._finish_load(op.clone(), view)
Expand Down

0 comments on commit f48b01a

Please sign in to comment.