diff --git a/lib/src/repo.rs b/lib/src/repo.rs index f7f8d68b6..5f440b150 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -725,8 +725,8 @@ impl MutableRepo { } } - pub fn remove_head(&mut self, head: &Commit) { - self.view.remove_head(head.id()); + pub fn remove_head(&mut self, head: &CommitId) { + self.view.remove_head(head); self.enforce_view_invariants(); self.invalidate_evolution(); } @@ -739,8 +739,8 @@ impl MutableRepo { } } - pub fn remove_public_head(&mut self, head: &Commit) { - self.view.remove_public_head(head.id()); + pub fn remove_public_head(&mut self, head: &CommitId) { + self.view.remove_public_head(head); self.invalidate_evolution(); } diff --git a/lib/tests/test_evolution.rs b/lib/tests/test_evolution.rs index 3258495ef..abe20ec2b 100644 --- a/lib/tests/test_evolution.rs +++ b/lib/tests/test_evolution.rs @@ -73,7 +73,7 @@ fn test_obsolete_and_orphan(use_git: bool) { assert!(!mut_repo.evolution().is_orphan(rewritten.id())); // It should no longer be obsolete if we remove the successor. - mut_repo.remove_head(&rewritten); + mut_repo.remove_head(rewritten.id()); assert!(!mut_repo.evolution().is_obsolete(original.id())); assert!(!mut_repo.evolution().is_orphan(child.id())); assert!(!mut_repo.evolution().is_orphan(grandchild.id())); diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index be287aba6..0b835cbcc 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -255,7 +255,7 @@ fn test_index_commits_previous_operations(use_git: bool) { let repo = tx.commit(); let mut tx = repo.start_transaction("test"); - tx.mut_repo().remove_head(&commit_c); + tx.mut_repo().remove_head(commit_c.id()); let repo = tx.commit(); // Delete index from disk diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index 953a9ccb5..3f32dde5c 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -52,7 +52,7 @@ fn test_load_at_operation(use_git: bool) { let repo = tx.commit(); let mut tx = repo.start_transaction("remove commit"); - tx.mut_repo().remove_head(&commit); + tx.mut_repo().remove_head(commit.id()); tx.commit(); // If we load the repo at head, we should not see the commit since it was diff --git a/lib/tests/test_mut_repo.rs b/lib/tests/test_mut_repo.rs index f827503c8..2483f4aed 100644 --- a/lib/tests/test_mut_repo.rs +++ b/lib/tests/test_mut_repo.rs @@ -428,7 +428,7 @@ fn test_remove_head(use_git: bool) { let mut tx = repo.start_transaction("test"); let mut_repo = tx.mut_repo(); assert!(mut_repo.view().heads().contains(commit3.id())); - mut_repo.remove_head(&commit3); + mut_repo.remove_head(commit3.id()); let heads = mut_repo.view().heads().clone(); assert!(!heads.contains(commit3.id())); assert!(!heads.contains(commit2.id())); @@ -474,7 +474,7 @@ fn test_remove_head_ancestor_git_ref(use_git: bool) { let mut_repo = tx.mut_repo(); let heads = mut_repo.view().heads().clone(); assert!(heads.contains(commit5.id())); - mut_repo.remove_head(&commit5); + mut_repo.remove_head(commit5.id()); let heads = mut_repo.view().heads().clone(); assert!(!heads.contains(commit5.id())); assert!(heads.contains(commit4.id())); @@ -552,7 +552,7 @@ fn test_remove_public_head(use_git: bool) { let mut tx = repo.start_transaction("test"); let mut_repo = tx.mut_repo(); assert!(mut_repo.view().public_heads().contains(commit1.id())); - mut_repo.remove_public_head(&commit1); + mut_repo.remove_public_head(commit1.id()); assert!(!mut_repo.view().public_heads().contains(commit1.id())); let repo = tx.commit(); assert!(!repo.view().public_heads().contains(commit1.id())); diff --git a/lib/tests/test_view.rs b/lib/tests/test_view.rs index c171faee3..a525e4fa7 100644 --- a/lib/tests/test_view.rs +++ b/lib/tests/test_view.rs @@ -100,8 +100,9 @@ fn test_merge_views_heads() { let repo = tx.commit(); let mut tx1 = repo.start_transaction("test"); - tx1.mut_repo().remove_head(&head_remove_tx1); - tx1.mut_repo().remove_public_head(&public_head_remove_tx1); + tx1.mut_repo().remove_head(head_remove_tx1.id()); + tx1.mut_repo() + .remove_public_head(public_head_remove_tx1.id()); let head_add_tx1 = testutils::create_random_commit(&settings, &repo).write_to_repo(tx1.mut_repo()); let public_head_add_tx1 = @@ -110,8 +111,9 @@ fn test_merge_views_heads() { tx1.commit(); let mut tx2 = repo.start_transaction("test"); - tx2.mut_repo().remove_head(&head_remove_tx2); - tx2.mut_repo().remove_public_head(&public_head_remove_tx2); + tx2.mut_repo().remove_head(head_remove_tx2.id()); + tx2.mut_repo() + .remove_public_head(public_head_remove_tx2.id()); let head_add_tx2 = testutils::create_random_commit(&settings, &repo).write_to_repo(tx2.mut_repo()); let public_head_add_tx2 = diff --git a/src/commands.rs b/src/commands.rs index 570f26662..08b999a9b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -2370,9 +2370,9 @@ fn cmd_discard( let mut tx = repo_command.start_transaction(&format!("discard commit {}", commit.id().hex())); let mut_repo = tx.mut_repo(); if sub_matches.is_present("public") { - mut_repo.remove_public_head(&commit); + mut_repo.remove_public_head(commit.id()); } else { - mut_repo.remove_head(&commit); + mut_repo.remove_head(commit.id()); } for parent in commit.parents() { mut_repo.add_head(&parent);