mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-10 14:16:24 +03:00
repo: remove init_*()
functions used only in tests
The `ReadonlyRepo::init_*()` functions were unused or used only in tests. Let's remove them, thereby making the repo less aware of specific backend implementations.
This commit is contained in:
parent
e41acc1c16
commit
c02f87170d
@ -128,30 +128,6 @@ impl Debug for ReadonlyRepo {
|
||||
}
|
||||
|
||||
impl ReadonlyRepo {
|
||||
pub fn init_local(settings: &UserSettings, repo_path: &Path) -> Arc<ReadonlyRepo> {
|
||||
Self::init(settings, repo_path, |store_path| {
|
||||
Box::new(LocalBackend::init(store_path))
|
||||
})
|
||||
}
|
||||
|
||||
/// Initializes a repo with a new Git backend in .jj/git/ (bare Git repo)
|
||||
pub fn init_internal_git(settings: &UserSettings, repo_path: &Path) -> Arc<ReadonlyRepo> {
|
||||
Self::init(settings, repo_path, |store_path| {
|
||||
Box::new(GitBackend::init_internal(store_path))
|
||||
})
|
||||
}
|
||||
|
||||
/// Initializes a repo with an existing Git backend at the specified path
|
||||
pub fn init_external_git(
|
||||
settings: &UserSettings,
|
||||
repo_path: &Path,
|
||||
git_repo_path: &Path,
|
||||
) -> Arc<ReadonlyRepo> {
|
||||
Self::init(settings, repo_path, |store_path| {
|
||||
Box::new(GitBackend::init_external(store_path, git_repo_path))
|
||||
})
|
||||
}
|
||||
|
||||
fn init_repo_dir(repo_path: &Path) {
|
||||
fs::create_dir(repo_path.join("store")).unwrap();
|
||||
fs::create_dir(repo_path.join("op_store")).unwrap();
|
||||
|
@ -108,6 +108,8 @@ impl Workspace {
|
||||
})
|
||||
}
|
||||
|
||||
/// Initializes a workspace with a new Git backend in .jj/git/ (bare Git
|
||||
/// repo)
|
||||
pub fn init_internal_git(
|
||||
user_settings: &UserSettings,
|
||||
workspace_root: &Path,
|
||||
@ -117,6 +119,8 @@ impl Workspace {
|
||||
})
|
||||
}
|
||||
|
||||
/// Initializes a workspace with an existing Git backend at the specified
|
||||
/// path
|
||||
pub fn init_external_git(
|
||||
user_settings: &UserSettings,
|
||||
workspace_root: &Path,
|
||||
|
@ -19,6 +19,7 @@ use git2::Oid;
|
||||
use jujutsu_lib::backend::CommitId;
|
||||
use jujutsu_lib::commit::Commit;
|
||||
use jujutsu_lib::git::{GitFetchError, GitPushError, GitRefUpdate};
|
||||
use jujutsu_lib::git_backend::GitBackend;
|
||||
use jujutsu_lib::op_store::{BranchTarget, RefTarget};
|
||||
use jujutsu_lib::repo::ReadonlyRepo;
|
||||
use jujutsu_lib::settings::UserSettings;
|
||||
@ -284,7 +285,9 @@ impl GitRepoData {
|
||||
git2::Repository::clone(origin_repo_dir.to_str().unwrap(), &git_repo_dir).unwrap();
|
||||
let jj_repo_dir = temp_dir.path().join("jj");
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let repo = ReadonlyRepo::init_external_git(&settings, &jj_repo_dir, &git_repo_dir);
|
||||
let repo = ReadonlyRepo::init(&settings, &jj_repo_dir, |store_path| {
|
||||
Box::new(GitBackend::init_external(store_path, &git_repo_dir))
|
||||
});
|
||||
Self {
|
||||
settings,
|
||||
_temp_dir: temp_dir,
|
||||
@ -520,7 +523,9 @@ fn test_init() {
|
||||
let initial_git_commit = empty_git_commit(&git_repo, "refs/heads/main", &[]);
|
||||
let initial_commit_id = commit_id(&initial_git_commit);
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let repo = ReadonlyRepo::init_external_git(&settings, &jj_repo_dir, &git_repo_dir);
|
||||
let repo = ReadonlyRepo::init(&settings, &jj_repo_dir, |store_path| {
|
||||
Box::new(GitBackend::init_external(store_path, &git_repo_dir))
|
||||
});
|
||||
// The refs were *not* imported -- it's the caller's responsibility to import
|
||||
// any refs they care about.
|
||||
assert!(!repo.view().heads().contains(&initial_commit_id));
|
||||
@ -682,7 +687,9 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet
|
||||
let initial_commit_id = commit_id(&initial_git_commit);
|
||||
git2::Repository::clone(source_repo_dir.to_str().unwrap(), &clone_repo_dir).unwrap();
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let jj_repo = ReadonlyRepo::init_external_git(settings, &jj_repo_dir, &clone_repo_dir);
|
||||
let jj_repo = ReadonlyRepo::init(settings, &jj_repo_dir, |store_path| {
|
||||
Box::new(GitBackend::init_external(store_path, &clone_repo_dir))
|
||||
});
|
||||
let mut tx = jj_repo.start_transaction("test");
|
||||
let new_commit = testutils::create_random_commit(settings, &jj_repo)
|
||||
.set_parents(vec![initial_commit_id])
|
||||
|
Loading…
Reference in New Issue
Block a user