Skip to content

Commit 1307ee5

Browse files
committed
refactor!(pytest plugin[hg]) Cache hg_repo
1 parent 3c6a0ae commit 1307ee5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/libvcs/pytest_plugin.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,26 @@ def git_repo(
653653

654654

655655
@pytest.fixture
656-
def hg_repo(projects_path: pathlib.Path, hg_remote_repo: pathlib.Path) -> HgSync:
656+
def hg_repo(
657+
remote_repos_path: pathlib.Path,
658+
projects_path: pathlib.Path,
659+
hg_remote_repo: pathlib.Path,
660+
) -> HgSync:
657661
"""Pre-made hg clone of remote repo checked out to user's projects dir."""
662+
remote_repo_name = unique_repo_name(remote_repos_path=projects_path)
663+
new_checkout_path = projects_path / remote_repo_name
664+
master_copy = remote_repos_path / "hg_repo"
665+
666+
if master_copy.exists():
667+
shutil.copytree(master_copy, new_checkout_path)
668+
return HgSync(
669+
url=f"file://{hg_remote_repo}",
670+
path=str(new_checkout_path),
671+
)
672+
658673
hg_repo = HgSync(
659674
url=f"file://{hg_remote_repo}",
660-
path=str(projects_path / "hg_repo"),
675+
path=master_copy,
661676
)
662677
hg_repo.obtain()
663678
return hg_repo

0 commit comments

Comments
 (0)