示例#1
0
def _vcs_add(script: PipTestEnvironment,
             version_pkg_path: Path,
             vcs: str = "git") -> Path:
    if vcs == "git":
        script.run("git", "init", cwd=version_pkg_path)
        script.run("git", "add", ".", cwd=version_pkg_path)
        _git_commit(script, version_pkg_path, message="initial version")
    elif vcs == "hg":
        script.run("hg", "init", cwd=version_pkg_path)
        script.run("hg", "add", ".", cwd=version_pkg_path)
        script.run(
            "hg",
            "commit",
            "-q",
            "--user",
            "pip <*****@*****.**>",
            "-m",
            "initial version",
            cwd=version_pkg_path,
        )
    elif vcs == "svn":
        repo_url = _create_svn_repo(script, version_pkg_path)
        script.run("svn",
                   "checkout",
                   repo_url,
                   "pip-test-package",
                   cwd=script.scratch_path)
        checkout_path: str = script.scratch_path / "pip-test-package"

        # svn internally stores windows drives as uppercase; we'll match that.
        checkout_path = Path(checkout_path.replace("c:", "C:"))

        version_pkg_path = checkout_path
    elif vcs == "bazaar":
        script.run("bzr", "init", cwd=version_pkg_path)
        script.run("bzr", "add", ".", cwd=version_pkg_path)
        script.run("bzr",
                   "whoami",
                   "pip <*****@*****.**>",
                   cwd=version_pkg_path)
        script.run(
            "bzr",
            "commit",
            "-q",
            "--author",
            "pip <*****@*****.**>",
            "-m",
            "initial version",
            cwd=version_pkg_path,
        )
    else:
        raise ValueError(f"Unknown vcs: {vcs}")
    return version_pkg_path