Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
64d205e8
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
64d205e8
编写于
7月 07, 2018
作者:
C
Chris Jerdonek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor out a new VersionControl.fetch_new() method.
上级
ca3b5bd4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
76 addition
and
52 deletion
+76
-52
news/052A794E-8CDC-4F3D-9B06-D195A6C35FD4.trivial
news/052A794E-8CDC-4F3D-9B06-D195A6C35FD4.trivial
+0
-0
src/pip/_internal/vcs/__init__.py
src/pip/_internal/vcs/__init__.py
+11
-0
src/pip/_internal/vcs/bazaar.py
src/pip/_internal/vcs/bazaar.py
+12
-9
src/pip/_internal/vcs/git.py
src/pip/_internal/vcs/git.py
+28
-24
src/pip/_internal/vcs/mercurial.py
src/pip/_internal/vcs/mercurial.py
+13
-10
src/pip/_internal/vcs/subversion.py
src/pip/_internal/vcs/subversion.py
+12
-9
未找到文件。
news/052A794E-8CDC-4F3D-9B06-D195A6C35FD4.trivial
0 → 100644
浏览文件 @
64d205e8
src/pip/_internal/vcs/__init__.py
浏览文件 @
64d205e8
...
...
@@ -260,6 +260,17 @@ class VersionControl(object):
"""
raise
NotImplementedError
def
fetch_new
(
self
,
dest
,
url
,
rev_options
):
"""
Fetch a revision from a repository, in the case that this is the
first fetch from the repository.
Args:
dest: the directory to fetch the repository to.
rev_options: a RevOptions object.
"""
raise
NotImplementedError
def
switch
(
self
,
dest
,
url
,
rev_options
):
"""
Switch the repo at ``dest`` to point to ``URL``.
...
...
src/pip/_internal/vcs/bazaar.py
浏览文件 @
64d205e8
...
...
@@ -48,6 +48,17 @@ class Bazaar(VersionControl):
cwd
=
temp_dir
.
path
,
show_stdout
=
False
,
)
def
fetch_new
(
self
,
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Checking out %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
cmd_args
=
[
'branch'
,
'-q'
]
+
rev_options
.
to_args
()
+
[
url
,
dest
]
self
.
run_command
(
cmd_args
)
def
switch
(
self
,
dest
,
url
,
rev_options
):
self
.
run_command
([
'switch'
,
url
],
cwd
=
dest
)
...
...
@@ -59,15 +70,7 @@ class Bazaar(VersionControl):
url
,
rev
=
self
.
get_url_rev
()
rev_options
=
self
.
make_rev_options
(
rev
)
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Checking out %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
cmd_args
=
[
'branch'
,
'-q'
]
+
rev_options
.
to_args
()
+
[
url
,
dest
]
self
.
run_command
(
cmd_args
)
self
.
fetch_new
(
dest
,
url
,
rev_options
)
def
get_url_rev
(
self
):
# hotfix the URL scheme after removing bzr+ from bzr+ssh:// readd it
...
...
src/pip/_internal/vcs/git.py
浏览文件 @
64d205e8
...
...
@@ -155,6 +155,33 @@ class Git(VersionControl):
return
self
.
get_revision
(
dest
)
==
name
def
fetch_new
(
self
,
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Cloning %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
self
.
run_command
([
'clone'
,
'-q'
,
url
,
dest
])
if
rev_options
.
rev
:
# Then a specific revision was requested.
rev_options
=
self
.
check_rev_options
(
dest
,
rev_options
)
# Only do a checkout if the current commit id doesn't match
# the requested revision.
if
not
self
.
is_commit_id_equal
(
dest
,
rev_options
.
rev
):
rev
=
rev_options
.
rev
# Only fetch the revision if it's a ref
if
rev
.
startswith
(
'refs/'
):
self
.
run_command
(
[
'fetch'
,
'-q'
,
url
]
+
rev_options
.
to_args
(),
cwd
=
dest
,
)
# Change the revision to the SHA of the ref we fetched
rev
=
'FETCH_HEAD'
self
.
run_command
([
'checkout'
,
'-q'
,
rev
],
cwd
=
dest
)
#: repo may contain submodules
self
.
update_submodules
(
dest
)
def
switch
(
self
,
dest
,
url
,
rev_options
):
self
.
run_command
([
'config'
,
'remote.origin.url'
,
url
],
cwd
=
dest
)
cmd_args
=
[
'checkout'
,
'-q'
]
+
rev_options
.
to_args
()
...
...
@@ -180,30 +207,7 @@ class Git(VersionControl):
url
,
rev
=
self
.
get_url_rev
()
rev_options
=
self
.
make_rev_options
(
rev
)
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Cloning %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
self
.
run_command
([
'clone'
,
'-q'
,
url
,
dest
])
if
rev
:
rev_options
=
self
.
check_rev_options
(
dest
,
rev_options
)
# Only do a checkout if the current commit id doesn't match
# the requested revision.
if
not
self
.
is_commit_id_equal
(
dest
,
rev_options
.
rev
):
rev
=
rev_options
.
rev
# Only fetch the revision if it's a ref
if
rev
.
startswith
(
'refs/'
):
self
.
run_command
(
[
'fetch'
,
'-q'
,
url
]
+
rev_options
.
to_args
(),
cwd
=
dest
,
)
# Change the revision to the SHA of the ref we fetched
rev
=
'FETCH_HEAD'
self
.
run_command
([
'checkout'
,
'-q'
,
rev
],
cwd
=
dest
)
#: repo may contain submodules
self
.
update_submodules
(
dest
)
self
.
fetch_new
(
dest
,
url
,
rev_options
)
def
get_url
(
self
,
location
):
"""Return URL of the first remote encountered."""
...
...
src/pip/_internal/vcs/mercurial.py
浏览文件 @
64d205e8
...
...
@@ -31,6 +31,18 @@ class Mercurial(VersionControl):
[
'archive'
,
location
],
show_stdout
=
False
,
cwd
=
temp_dir
.
path
)
def
fetch_new
(
self
,
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Cloning hg %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
self
.
run_command
([
'clone'
,
'--noupdate'
,
'-q'
,
url
,
dest
])
cmd_args
=
[
'update'
,
'-q'
]
+
rev_options
.
to_args
()
self
.
run_command
(
cmd_args
,
cwd
=
dest
)
def
switch
(
self
,
dest
,
url
,
rev_options
):
repo_config
=
os
.
path
.
join
(
dest
,
self
.
dirname
,
'hgrc'
)
config
=
configparser
.
SafeConfigParser
()
...
...
@@ -56,16 +68,7 @@ class Mercurial(VersionControl):
url
,
rev
=
self
.
get_url_rev
()
rev_options
=
self
.
make_rev_options
(
rev
)
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Cloning hg %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
self
.
run_command
([
'clone'
,
'--noupdate'
,
'-q'
,
url
,
dest
])
cmd_args
=
[
'update'
,
'-q'
]
+
rev_options
.
to_args
()
self
.
run_command
(
cmd_args
,
cwd
=
dest
)
self
.
fetch_new
(
dest
,
url
,
rev_options
)
def
get_url
(
self
,
location
):
url
=
self
.
run_command
(
...
...
src/pip/_internal/vcs/subversion.py
浏览文件 @
64d205e8
...
...
@@ -73,6 +73,17 @@ class Subversion(VersionControl):
cmd_args
=
[
'export'
]
+
rev_options
.
to_args
()
+
[
url
,
location
]
self
.
run_command
(
cmd_args
,
show_stdout
=
False
)
def
fetch_new
(
self
,
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Checking out %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
cmd_args
=
[
'checkout'
,
'-q'
]
+
rev_options
.
to_args
()
+
[
url
,
dest
]
self
.
run_command
(
cmd_args
)
def
switch
(
self
,
dest
,
url
,
rev_options
):
cmd_args
=
[
'switch'
]
+
rev_options
.
to_args
()
+
[
url
,
dest
]
self
.
run_command
(
cmd_args
)
...
...
@@ -86,15 +97,7 @@ class Subversion(VersionControl):
rev_options
=
get_rev_options
(
self
,
url
,
rev
)
url
=
remove_auth_from_url
(
url
)
if
self
.
check_destination
(
dest
,
url
,
rev_options
):
rev_display
=
rev_options
.
to_display
()
logger
.
info
(
'Checking out %s%s to %s'
,
url
,
rev_display
,
display_path
(
dest
),
)
cmd_args
=
[
'checkout'
,
'-q'
]
+
rev_options
.
to_args
()
+
[
url
,
dest
]
self
.
run_command
(
cmd_args
)
self
.
fetch_new
(
dest
,
url
,
rev_options
)
def
get_location
(
self
,
dist
,
dependency_links
):
for
url
in
dependency_links
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录