Skip to content

Commit ef7dd54

Browse files
committed
!squash more caching
1 parent 6ee6b77 commit ef7dd54

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

src/libvcs/pytest_plugin.py

+38-8
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,34 @@ def svn_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> N
449449
)
450450

451451

452+
@pytest.fixture(scope="session")
453+
def empty_svn_repo_path(libvcs_test_cache_path: pathlib.Path) -> pathlib.Path:
454+
"""Return temporary directory to use for master-copy of a svn repo."""
455+
return libvcs_test_cache_path / "empty_svn_repo"
456+
457+
458+
@pytest.fixture(scope="session")
459+
@skip_if_svn_missing
460+
def empty_svn_repo(
461+
empty_svn_repo_path: pathlib.Path,
462+
) -> pathlib.Path:
463+
"""Return factory to create svn remote repo to for clone / push purposes."""
464+
if empty_svn_repo_path.exists() and (empty_svn_repo_path / ".git").exists():
465+
return empty_svn_repo_path
466+
467+
return _create_svn_remote_repo(
468+
remote_repos_path=empty_svn_repo_path.parent,
469+
remote_repo_name=empty_svn_repo_path.stem,
470+
remote_repo_post_init=None,
471+
init_cmd_args=None,
472+
)
473+
474+
452475
@pytest.fixture
453476
@skip_if_svn_missing
454477
def create_svn_remote_repo(
455478
remote_repos_path: pathlib.Path,
479+
empty_svn_repo: pathlib.Path,
456480
) -> CreateRepoPytestFixtureFn:
457481
"""Pre-made svn repo, bare, used as a file:// remote to checkout and commit to."""
458482

@@ -462,14 +486,20 @@ def fn(
462486
remote_repo_post_init: Optional[CreateRepoPostInitFn] = None,
463487
init_cmd_args: InitCmdArgs = None,
464488
) -> pathlib.Path:
465-
return _create_svn_remote_repo(
466-
remote_repos_path=remote_repos_path,
467-
remote_repo_name=remote_repo_name
468-
if remote_repo_name is not None
469-
else unique_repo_name(remote_repos_path=remote_repos_path),
470-
remote_repo_post_init=remote_repo_post_init,
471-
init_cmd_args=init_cmd_args,
472-
)
489+
if remote_repo_name is None:
490+
remote_repo_name = unique_repo_name(remote_repos_path=remote_repos_path)
491+
remote_repo_path = remote_repos_path / remote_repo_name
492+
493+
shutil.copytree(empty_svn_repo, remote_repo_path)
494+
495+
if remote_repo_post_init is not None and callable(remote_repo_post_init):
496+
remote_repo_post_init(remote_repo_path=remote_repo_path)
497+
498+
assert empty_svn_repo.exists()
499+
500+
assert remote_repo_path.exists()
501+
502+
return remote_repo_path
473503

474504
return fn
475505

0 commit comments

Comments
 (0)