forked from mirrors/jj
tests: add a helper for building commit graphs when only topology is important
This commit is contained in:
parent
419002fab4
commit
df2caab274
5 changed files with 132 additions and 188 deletions
|
@ -19,8 +19,9 @@ use std::sync::Arc;
|
|||
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::commit::Commit;
|
||||
use crate::commit_builder::CommitBuilder;
|
||||
use crate::repo::ReadonlyRepo;
|
||||
use crate::repo::{MutableRepo, ReadonlyRepo};
|
||||
use crate::repo_path::{DirRepoPath, FileRepoPath};
|
||||
use crate::settings::UserSettings;
|
||||
use crate::store::{FileId, TreeId, TreeValue};
|
||||
|
@ -129,3 +130,29 @@ pub fn write_working_copy_file(repo: &ReadonlyRepo, path: &FileRepoPath, content
|
|||
.unwrap();
|
||||
file.write_all(contents.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
pub struct CommitGraphBuilder<'settings, 'repo> {
|
||||
settings: &'settings UserSettings,
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
}
|
||||
|
||||
impl<'settings, 'repo> CommitGraphBuilder<'settings, 'repo> {
|
||||
pub fn new(
|
||||
settings: &'settings UserSettings,
|
||||
mut_repo: &'repo mut MutableRepo,
|
||||
) -> CommitGraphBuilder<'settings, 'repo> {
|
||||
CommitGraphBuilder { settings, mut_repo }
|
||||
}
|
||||
|
||||
pub fn initial_commit(&mut self) -> Commit {
|
||||
create_random_commit(self.settings, self.mut_repo.base_repo().as_ref())
|
||||
.write_to_repo(self.mut_repo)
|
||||
}
|
||||
|
||||
pub fn commit_with_parents(&mut self, parents: &[&Commit]) -> Commit {
|
||||
let parent_ids: Vec<_> = parents.iter().map(|commit| commit.id().clone()).collect();
|
||||
create_random_commit(self.settings, self.mut_repo.base_repo().as_ref())
|
||||
.set_parents(parent_ids)
|
||||
.write_to_repo(self.mut_repo)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use jujube_lib::repo::ReadonlyRepo;
|
|||
use jujube_lib::settings::UserSettings;
|
||||
use jujube_lib::store::CommitId;
|
||||
use jujube_lib::testutils;
|
||||
use jujube_lib::testutils::create_random_commit;
|
||||
use jujube_lib::testutils::{create_random_commit, CommitGraphBuilder};
|
||||
use test_case::test_case;
|
||||
|
||||
#[must_use]
|
||||
|
@ -85,16 +85,15 @@ fn test_index_commits_standard_cases(use_git: bool) {
|
|||
let root_commit = repo.store().root_commit();
|
||||
let wc_commit = repo.working_copy_locked().current_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let commit_a = child_commit(&settings, &repo, &root_commit).write_to_repo(tx.mut_repo());
|
||||
let commit_b = child_commit(&settings, &repo, &commit_a).write_to_repo(tx.mut_repo());
|
||||
let commit_c = child_commit(&settings, &repo, &commit_a).write_to_repo(tx.mut_repo());
|
||||
let commit_d = child_commit(&settings, &repo, &commit_c).write_to_repo(tx.mut_repo());
|
||||
let commit_e = child_commit(&settings, &repo, &commit_d).write_to_repo(tx.mut_repo());
|
||||
let commit_f = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit_b.id().clone(), commit_e.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let commit_g = child_commit(&settings, &repo, &commit_f).write_to_repo(tx.mut_repo());
|
||||
let commit_h = child_commit(&settings, &repo, &commit_e).write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
let commit_c = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
let commit_d = graph_builder.commit_with_parents(&[&commit_c]);
|
||||
let commit_e = graph_builder.commit_with_parents(&[&commit_d]);
|
||||
let commit_f = graph_builder.commit_with_parents(&[&commit_b, &commit_e]);
|
||||
let commit_g = graph_builder.commit_with_parents(&[&commit_f]);
|
||||
let commit_h = graph_builder.commit_with_parents(&[&commit_e]);
|
||||
tx.commit();
|
||||
repo = repo.reload().unwrap();
|
||||
|
||||
|
@ -141,29 +140,19 @@ fn test_index_commits_criss_cross(use_git: bool) {
|
|||
let (_temp_dir, mut repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let num_generations = 50;
|
||||
let root_commit = repo.store().root_commit();
|
||||
|
||||
// Create a long chain of criss-crossed merges. If they were traversed without
|
||||
// keeping track of visited nodes, it would be 2^50 visits, so if this test
|
||||
// finishes in reasonable time, we know that we don't do a naive traversal.
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut left_commits =
|
||||
vec![child_commit(&settings, &repo, &root_commit).write_to_repo(tx.mut_repo())];
|
||||
let mut right_commits =
|
||||
vec![child_commit(&settings, &repo, &root_commit).write_to_repo(tx.mut_repo())];
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let mut left_commits = vec![graph_builder.initial_commit()];
|
||||
let mut right_commits = vec![graph_builder.initial_commit()];
|
||||
for gen in 1..num_generations {
|
||||
let new_left = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![
|
||||
left_commits[gen - 1].id().clone(),
|
||||
right_commits[gen - 1].id().clone(),
|
||||
])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let new_right = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![
|
||||
left_commits[gen - 1].id().clone(),
|
||||
right_commits[gen - 1].id().clone(),
|
||||
])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let new_left =
|
||||
graph_builder.commit_with_parents(&[&left_commits[gen - 1], &right_commits[gen - 1]]);
|
||||
let new_right =
|
||||
graph_builder.commit_with_parents(&[&left_commits[gen - 1], &right_commits[gen - 1]]);
|
||||
left_commits.push(new_left);
|
||||
right_commits.push(new_right);
|
||||
}
|
||||
|
@ -260,11 +249,11 @@ fn test_index_commits_previous_operations(use_git: bool) {
|
|||
// |/
|
||||
// o root
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let commit_a = child_commit(&settings, &repo, &root_commit).write_to_repo(tx.mut_repo());
|
||||
let commit_b = child_commit(&settings, &repo, &commit_a).write_to_repo(tx.mut_repo());
|
||||
let commit_c = child_commit(&settings, &repo, &commit_b).write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit_a = graph_builder.initial_commit();
|
||||
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
||||
let commit_c = graph_builder.commit_with_parents(&[&commit_b]);
|
||||
tx.commit();
|
||||
repo = repo.reload().unwrap();
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use jujube_lib::repo_path::FileRepoPath;
|
|||
use jujube_lib::store::{Conflict, ConflictId, ConflictPart, TreeValue};
|
||||
use jujube_lib::store_wrapper::StoreWrapper;
|
||||
use jujube_lib::testutils;
|
||||
use jujube_lib::testutils::CommitGraphBuilder;
|
||||
use test_case::test_case;
|
||||
|
||||
// TODO Many of the tests here are not run with Git because they end up creating
|
||||
|
@ -350,13 +351,10 @@ fn test_add_head_ancestor(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(tx.mut_repo());
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let _commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let _commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
tx.commit();
|
||||
let repo = repo.reload().unwrap();
|
||||
|
||||
|
@ -435,13 +433,10 @@ fn test_remove_head(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(tx.mut_repo());
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
tx.commit();
|
||||
let repo = repo.reload().unwrap();
|
||||
|
||||
|
@ -477,15 +472,12 @@ fn test_remove_head_ancestor_git_ref(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
mut_repo.insert_git_ref("refs/heads/main".to_string(), commit1.id().clone());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
tx.mut_repo()
|
||||
.insert_git_ref("refs/heads/main".to_string(), commit1.id().clone());
|
||||
tx.commit();
|
||||
let repo = repo.reload().unwrap();
|
||||
|
||||
|
@ -539,12 +531,10 @@ fn test_add_public_head_ancestor(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
mut_repo.add_public_head(&commit2);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
tx.mut_repo().add_public_head(&commit2);
|
||||
tx.commit();
|
||||
let repo = repo.reload().unwrap();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use jujube_lib::repo::RepoRef;
|
|||
use jujube_lib::revset::{evaluate_expression, parse, resolve_symbol, RevsetError};
|
||||
use jujube_lib::store::{CommitId, MillisSinceEpoch, Signature, Timestamp};
|
||||
use jujube_lib::testutils;
|
||||
use jujube_lib::testutils::CommitGraphBuilder;
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(false ; "local store")]
|
||||
|
@ -267,21 +268,15 @@ fn test_evaluate_expression_parents(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone(), commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit5 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.initial_commit();
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit2, &commit3]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
||||
// The root commit has no parents
|
||||
assert_eq!(resolve_commit_ids(mut_repo.as_repo_ref(), ":root"), vec![]);
|
||||
|
@ -402,20 +397,14 @@ fn test_evaluate_expression_ancestors(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone(), commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit1, &commit3]);
|
||||
|
||||
// The ancestors of the root commit is just the root commit itself
|
||||
assert_eq!(
|
||||
|
@ -447,17 +436,11 @@ fn test_evaluate_expression_range(use_git: bool) {
|
|||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone(), commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit1, &commit3]);
|
||||
|
||||
// The range from the root to the root is empty (because the left side of the
|
||||
// range is exclusive)
|
||||
|
@ -515,23 +498,15 @@ fn test_evaluate_expression_dag_range(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit5 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit3.id().clone(), commit4.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit3, &commit4]);
|
||||
|
||||
// Can get DAG range of just the root commit
|
||||
assert_eq!(
|
||||
|
@ -665,12 +640,10 @@ fn test_evaluate_expression_all_heads(use_git: bool) {
|
|||
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let wc_commit = repo.working_copy_locked().current_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
|
||||
assert_eq!(
|
||||
resolve_commit_ids(mut_repo.as_repo_ref(), "all_heads()"),
|
||||
|
@ -686,12 +659,12 @@ fn test_evaluate_expression_public_heads(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.initial_commit();
|
||||
|
||||
// Can get public heads with root commit as only public head
|
||||
assert_eq!(
|
||||
|
@ -849,23 +822,15 @@ fn test_evaluate_expression_union(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit5 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
||||
// Union between ancestors
|
||||
assert_eq!(
|
||||
|
@ -931,23 +896,15 @@ fn test_evaluate_expression_intersection(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit5 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
||||
// Intersection between ancestors
|
||||
assert_eq!(
|
||||
|
@ -980,23 +937,15 @@ fn test_evaluate_expression_difference(use_git: bool) {
|
|||
let settings = testutils::user_settings();
|
||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let mut tx = repo.start_transaction("test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
|
||||
let root_commit = repo.store().root_commit();
|
||||
let commit1 = testutils::create_random_commit(&settings, &repo).write_to_repo(mut_repo);
|
||||
let commit2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit1.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit3 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit4 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit3.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let commit5 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![commit2.id().clone()])
|
||||
.write_to_repo(mut_repo);
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
||||
let commit1 = graph_builder.initial_commit();
|
||||
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
||||
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
||||
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
||||
|
||||
// Difference between ancestors
|
||||
assert_eq!(
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
use jujube_lib::testutils;
|
||||
use jujube_lib::testutils::CommitGraphBuilder;
|
||||
use maplit::hashset;
|
||||
use test_case::test_case;
|
||||
|
||||
|
@ -37,15 +38,10 @@ fn test_heads_fork(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
||||
let initial = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![repo.store().root_commit_id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let child1 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let child2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let initial = graph_builder.initial_commit();
|
||||
let child1 = graph_builder.commit_with_parents(&[&initial]);
|
||||
let child2 = graph_builder.commit_with_parents(&[&initial]);
|
||||
|
||||
let wc = repo.working_copy_locked();
|
||||
assert_eq!(
|
||||
|
@ -66,18 +62,11 @@ fn test_heads_merge(use_git: bool) {
|
|||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||
let mut tx = repo.start_transaction("test");
|
||||
|
||||
let initial = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![repo.store().root_commit_id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let child1 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let child2 = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![initial.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let merge = testutils::create_random_commit(&settings, &repo)
|
||||
.set_parents(vec![child1.id().clone(), child2.id().clone()])
|
||||
.write_to_repo(tx.mut_repo());
|
||||
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
||||
let initial = graph_builder.initial_commit();
|
||||
let child1 = graph_builder.commit_with_parents(&[&initial]);
|
||||
let child2 = graph_builder.commit_with_parents(&[&initial]);
|
||||
let merge = graph_builder.commit_with_parents(&[&child1, &child2]);
|
||||
|
||||
let wc = repo.working_copy_locked();
|
||||
assert_eq!(
|
||||
|
|
Loading…
Reference in a new issue