forked from mirrors/jj
transaction: remove add_head(), remove_head(), and set_view() helpers
This commit is contained in:
parent
06df609482
commit
f9873c49ec
4 changed files with 6 additions and 20 deletions
|
@ -64,21 +64,6 @@ impl<'r> Transaction<'r> {
|
|||
mut_repo.write_commit(commit)
|
||||
}
|
||||
|
||||
pub fn add_head(&mut self, head: &Commit) {
|
||||
let mut_repo = Arc::get_mut(self.repo.as_mut().unwrap()).unwrap();
|
||||
mut_repo.add_head(head)
|
||||
}
|
||||
|
||||
pub fn remove_head(&mut self, head: &Commit) {
|
||||
let mut_repo = Arc::get_mut(self.repo.as_mut().unwrap()).unwrap();
|
||||
mut_repo.remove_head(head)
|
||||
}
|
||||
|
||||
pub fn set_view(&mut self, data: op_store::View) {
|
||||
let mut_repo = Arc::get_mut(self.repo.as_mut().unwrap()).unwrap();
|
||||
mut_repo.set_view(data);
|
||||
}
|
||||
|
||||
/// Writes the transaction to the operation store and publishes it.
|
||||
pub fn commit(self) -> Operation {
|
||||
self.write().publish()
|
||||
|
|
|
@ -266,7 +266,7 @@ fn test_index_commits_previous_operations(use_git: bool) {
|
|||
Arc::get_mut(&mut repo).unwrap().reload();
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
tx.remove_head(&commit_c);
|
||||
tx.mut_repo().remove_head(&commit_c);
|
||||
tx.commit();
|
||||
Arc::get_mut(&mut repo).unwrap().reload();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ fn test_load_at_operation(use_git: bool) {
|
|||
Arc::get_mut(&mut repo).unwrap().reload();
|
||||
|
||||
let mut tx = repo.start_transaction("remove commit");
|
||||
tx.remove_head(&commit);
|
||||
tx.mut_repo().remove_head(&commit);
|
||||
tx.commit();
|
||||
|
||||
// If we load the repo at head, we should not see the commit since it was
|
||||
|
|
|
@ -1409,9 +1409,10 @@ fn cmd_discard(
|
|||
let mut_repo = Arc::get_mut(&mut repo).unwrap();
|
||||
let commit = resolve_revision_arg(ui, mut_repo, sub_matches)?;
|
||||
let mut tx = repo.start_transaction(&format!("discard commit {}", commit.id().hex()));
|
||||
tx.remove_head(&commit);
|
||||
let mut_repo = tx.mut_repo();
|
||||
mut_repo.remove_head(&commit);
|
||||
for parent in commit.parents() {
|
||||
tx.add_head(&parent);
|
||||
mut_repo.add_head(&parent);
|
||||
}
|
||||
// TODO: also remove descendants
|
||||
tx.commit();
|
||||
|
@ -2019,7 +2020,7 @@ fn cmd_op_restore(
|
|||
let owned_wc = repo.working_copy().clone();
|
||||
let target_op = resolve_single_op(&repo, _cmd_matches.value_of("operation").unwrap())?;
|
||||
let mut tx = repo.start_transaction(&format!("restore to operation {}", target_op.id().hex()));
|
||||
tx.set_view(target_op.view().take_store_view());
|
||||
tx.mut_repo().set_view(target_op.view().take_store_view());
|
||||
tx.commit();
|
||||
update_working_copy(
|
||||
ui,
|
||||
|
|
Loading…
Reference in a new issue