Skip to content

Commit 37d21bd

Browse files
committed
feat(pytest_plugin): Use SVN import dump
1 parent 404f80f commit 37d21bd

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,34 @@ def _create_svn_remote_repo(
276276
init_cmd_args = []
277277

278278
remote_repo_path = remote_repos_path / remote_repo_name
279-
run(["svnadmin", "create", remote_repo_path, *init_cmd_args])
279+
run(["svnadmin", "create", str(remote_repo_path), *init_cmd_args])
280+
281+
assert remote_repo_path.exists()
282+
assert remote_repo_path.is_dir()
280283

281284
if remote_repo_post_init is not None and callable(remote_repo_post_init):
282285
remote_repo_post_init(remote_repo_path=remote_repo_path)
283286

284287
return remote_repo_path
285288

286289

290+
def svn_remote_repo_single_commit_post_init(remote_repo_path: pathlib.Path) -> None:
291+
assert remote_repo_path.exists()
292+
repo_dumpfile = pathlib.Path(__file__).parent / "data" / "repotest.dump"
293+
run(
294+
" ".join(
295+
[
296+
"svnadmin",
297+
"load",
298+
str(remote_repo_path),
299+
"<",
300+
str(repo_dumpfile),
301+
]
302+
),
303+
shell=True,
304+
)
305+
306+
287307
@pytest.fixture
288308
@skip_if_svn_missing
289309
def create_svn_remote_repo(
@@ -313,10 +333,9 @@ def fn(
313333
@skip_if_svn_missing
314334
def svn_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path:
315335
"""Pre-made. Local file:// based SVN server."""
316-
svn_repo_name = "svn_server_dir"
317336
remote_repo_path = _create_svn_remote_repo(
318337
remote_repos_path=remote_repos_path,
319-
remote_repo_name=svn_repo_name,
338+
remote_repo_name="svn_server_dir",
320339
remote_repo_post_init=None,
321340
)
322341

@@ -456,7 +475,11 @@ def add_doctest_fixtures(
456475
doctest_namespace["create_git_remote_repo_bare"] = create_git_remote_repo
457476
doctest_namespace["git_local_clone"] = git_repo
458477
if shutil.which("svn"):
459-
doctest_namespace["create_svn_remote_repo"] = create_svn_remote_repo
478+
doctest_namespace["create_svn_remote_repo_bare"] = create_svn_remote_repo
479+
doctest_namespace["create_svn_remote_repo"] = functools.partial(
480+
create_svn_remote_repo,
481+
remote_repo_post_init=svn_remote_repo_single_commit_post_init,
482+
)
460483
if shutil.which("hg"):
461484
doctest_namespace["create_hg_remote_repo_bare"] = create_hg_remote_repo
462485
doctest_namespace["create_hg_remote_repo"] = functools.partial(

0 commit comments

Comments
 (0)