Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
144051e4
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
144051e4
编写于
9月 13, 2019
作者:
C
Chris Jerdonek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify local_repos.py.
上级
0a2238ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
45 deletion
+25
-45
tests/lib/local_repos.py
tests/lib/local_repos.py
+25
-45
未找到文件。
tests/lib/local_repos.py
浏览文件 @
144051e4
...
...
@@ -7,27 +7,32 @@ from pip._vendor.six.moves.urllib import request as urllib_request
from
pip._internal.utils.misc
import
hide_url
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
pip._internal.vcs
import
bazaar
,
git
,
mercurial
,
subversion
from
pip._internal.vcs
import
vcs
from
tests.lib
import
path_to_url
if
MYPY_CHECK_RUNNING
:
from
tests.lib.path
import
Path
def
_create_initools_repository
(
directory
):
subprocess
.
check_call
(
'svnadmin create INITools'
.
split
(),
cwd
=
directory
)
def
_ensure_svn_initools_repo
(
directory
):
"""
Create the SVN INITools repo if it doesn't already exist.
"""
initools_dir
=
os
.
path
.
join
(
directory
,
'INITools'
)
repo_url_path
=
os
.
path
.
join
(
initools_dir
,
'trunk'
)
if
os
.
path
.
exists
(
initools_dir
):
return
repo_url_path
subprocess
.
check_call
(
'svnadmin create INITools'
.
split
(),
cwd
=
directory
)
def
_dump_initools_repository
(
directory
):
filename
,
_
=
urllib_request
.
urlretrieve
(
'http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/'
'INITools_modified.dump'
)
initools_folder
=
os
.
path
.
join
(
directory
,
'INITools'
)
devnull
=
open
(
os
.
devnull
,
'w'
)
dump
=
open
(
filename
)
subprocess
.
check_call
(
[
'svnadmin'
,
'load'
,
initools_
folde
r
],
[
'svnadmin'
,
'load'
,
initools_
di
r
],
stdin
=
dump
,
stdout
=
devnull
,
)
...
...
@@ -35,41 +40,7 @@ def _dump_initools_repository(directory):
devnull
.
close
()
os
.
remove
(
filename
)
def
_create_svn_repository_for_initools
(
directory
):
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
directory
,
'INITools'
)):
_create_initools_repository
(
directory
)
_dump_initools_repository
(
directory
)
def
_get_vcs_and_checkout_url
(
remote_repository
,
directory
):
vcs_classes
=
{
'svn'
:
subversion
.
Subversion
,
'git'
:
git
.
Git
,
'bzr'
:
bazaar
.
Bazaar
,
'hg'
:
mercurial
.
Mercurial
}
default_vcs
=
'svn'
if
'+'
not
in
remote_repository
:
remote_repository
=
'%s+%s'
%
(
default_vcs
,
remote_repository
)
vcs
,
repository_path
=
remote_repository
.
split
(
'+'
,
1
)
vcs_class
=
vcs_classes
[
vcs
]
branch
=
''
if
vcs
==
'svn'
:
branch
=
os
.
path
.
basename
(
remote_repository
)
# remove the slash
repository_name
=
os
.
path
.
basename
(
remote_repository
[:
-
len
(
branch
)
-
1
]
)
else
:
repository_name
=
os
.
path
.
basename
(
remote_repository
)
destination_path
=
os
.
path
.
join
(
directory
,
repository_name
)
if
not
os
.
path
.
exists
(
destination_path
):
url
=
hide_url
(
remote_repository
)
vcs_class
().
obtain
(
destination_path
,
url
=
url
)
return
'%s+%s'
%
(
vcs
,
path_to_url
(
'/'
.
join
([
directory
,
repository_name
,
branch
])),
)
return
repo_url_path
def
local_checkout
(
...
...
@@ -82,14 +53,23 @@ def local_checkout(
temp directory Path object unique to each test function invocation,
created as a sub directory of the base temp directory.
"""
assert
'+'
in
remote_repo
vcs_name
,
repository_path
=
remote_repo
.
split
(
'+'
,
1
)
directory
=
temp_path
.
joinpath
(
'cache'
)
if
not
os
.
path
.
exists
(
directory
):
os
.
mkdir
(
directory
)
# os.makedirs(directory)
if
remote_repo
.
startswith
(
'svn'
):
_create_svn_repository_for_initools
(
directory
)
return
_get_vcs_and_checkout_url
(
remote_repo
,
directory
)
if
vcs_name
==
'svn'
:
assert
remote_repo
.
endswith
(
'/INITools/trunk'
)
repo_url_path
=
_ensure_svn_initools_repo
(
directory
)
else
:
repository_name
=
os
.
path
.
basename
(
remote_repo
)
repo_url_path
=
os
.
path
.
join
(
directory
,
repository_name
)
vcs_backend
=
vcs
.
get_backend
(
vcs_name
)
vcs_backend
.
obtain
(
repo_url_path
,
url
=
hide_url
(
remote_repo
))
return
'{}+{}'
.
format
(
vcs_name
,
path_to_url
(
repo_url_path
))
def
local_repo
(
remote_repo
,
temp_path
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录