Skip to content

Commit d782b66

Browse files
committed
refactor!(pytest plugin[hg]) Cache hg_repo
1 parent 0799737 commit d782b66

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,20 @@ def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path) -> GitS
651651
@pytest.fixture
652652
def hg_repo(projects_path: pathlib.Path, hg_remote_repo: pathlib.Path) -> HgSync:
653653
"""Pre-made hg clone of remote repo checked out to user's projects dir."""
654+
remote_repo_name = unique_repo_name(remote_repos_path=projects_path)
655+
new_checkout_path = projects_path / remote_repo_name
656+
master_copy = projects_path / "hg_repo"
657+
658+
if master_copy.exists():
659+
shutil.copytree(master_copy, new_checkout_path)
660+
return HgSync(
661+
url=f"file://{hg_remote_repo}",
662+
path=str(new_checkout_path),
663+
)
664+
654665
hg_repo = HgSync(
655666
url=f"file://{hg_remote_repo}",
656-
path=str(projects_path / "hg_repo"),
667+
path=master_copy,
657668
)
658669
hg_repo.obtain()
659670
return hg_repo

0 commit comments

Comments
 (0)