Skip to content

Commit 0dd3a2b

Browse files
authored
Merge pull request #9713 from sbidoul/rm-vcs-export
Remove now unused VCS export code
2 parents 9e8a544 + ecdcfeb commit 0dd3a2b

File tree

7 files changed

+4
-132
lines changed

7 files changed

+4
-132
lines changed

src/pip/_internal/vcs/bazaar.py

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import logging
2-
import os
32
from typing import List, Optional, Tuple
43

5-
from pip._internal.utils.misc import HiddenText, display_path, rmtree
4+
from pip._internal.utils.misc import HiddenText, display_path
65
from pip._internal.utils.subprocess import make_command
76
from pip._internal.utils.urls import path_to_url
87
from pip._internal.vcs.versioncontrol import (
@@ -30,21 +29,6 @@ def get_base_rev_args(rev):
3029
# type: (str) -> List[str]
3130
return ['-r', rev]
3231

33-
def export(self, location, url):
34-
# type: (str, HiddenText) -> None
35-
"""
36-
Export the Bazaar repository at the url to the destination location
37-
"""
38-
# Remove the location to make sure Bazaar can export it correctly
39-
if os.path.exists(location):
40-
rmtree(location)
41-
42-
url, rev_options = self.get_url_rev_options(url)
43-
self.run_command(
44-
make_command('export', location, url, rev_options.to_args()),
45-
show_stdout=False,
46-
)
47-
4832
def fetch_new(self, dest, url, rev_options):
4933
# type: (str, HiddenText, RevOptions) -> None
5034
rev_display = rev_options.to_display()

src/pip/_internal/vcs/git.py

-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pip._internal.exceptions import BadCommand, InstallationError
1212
from pip._internal.utils.misc import HiddenText, display_path, hide_url
1313
from pip._internal.utils.subprocess import make_command
14-
from pip._internal.utils.temp_dir import TempDirectory
1514
from pip._internal.vcs.versioncontrol import (
1615
AuthInfo,
1716
RemoteNotFoundError,
@@ -112,19 +111,6 @@ def get_current_branch(cls, location):
112111

113112
return None
114113

115-
def export(self, location, url):
116-
# type: (str, HiddenText) -> None
117-
"""Export the Git repository at the url to the destination location"""
118-
if not location.endswith('/'):
119-
location = location + '/'
120-
121-
with TempDirectory(kind="export") as temp_dir:
122-
self.unpack(temp_dir.path, url=url)
123-
self.run_command(
124-
['checkout-index', '-a', '-f', '--prefix', location],
125-
show_stdout=False, cwd=temp_dir.path
126-
)
127-
128114
@classmethod
129115
def get_revision_sha(cls, dest, rev):
130116
# type: (str, str) -> Tuple[Optional[str], bool]

src/pip/_internal/vcs/mercurial.py

-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pip._internal.exceptions import BadCommand, InstallationError
77
from pip._internal.utils.misc import HiddenText, display_path
88
from pip._internal.utils.subprocess import make_command
9-
from pip._internal.utils.temp_dir import TempDirectory
109
from pip._internal.utils.urls import path_to_url
1110
from pip._internal.vcs.versioncontrol import (
1211
RevOptions,
@@ -31,16 +30,6 @@ def get_base_rev_args(rev):
3130
# type: (str) -> List[str]
3231
return [rev]
3332

34-
def export(self, location, url):
35-
# type: (str, HiddenText) -> None
36-
"""Export the Hg repository at the url to the destination location"""
37-
with TempDirectory(kind="export") as temp_dir:
38-
self.unpack(temp_dir.path, url=url)
39-
40-
self.run_command(
41-
['archive', location], show_stdout=False, cwd=temp_dir.path
42-
)
43-
4433
def fetch_new(self, dest, url, rev_options):
4534
# type: (str, HiddenText, RevOptions) -> None
4635
rev_display = rev_options.to_display()

src/pip/_internal/vcs/subversion.py

-20
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import re
44
from typing import List, Optional, Tuple
55

6-
from pip._internal.utils.logging import indent_log
76
from pip._internal.utils.misc import (
87
HiddenText,
98
display_path,
109
is_console_interactive,
11-
rmtree,
1210
split_auth_from_netloc,
1311
)
1412
from pip._internal.utils.subprocess import CommandArgs, make_command
@@ -272,7 +270,6 @@ def get_remote_call_options(self):
272270
in this class.
273271
274272
- checkout
275-
- export
276273
- switch
277274
- update
278275
@@ -297,23 +294,6 @@ def get_remote_call_options(self):
297294

298295
return []
299296

300-
def export(self, location, url):
301-
# type: (str, HiddenText) -> None
302-
"""Export the svn repository at the url to the destination location"""
303-
url, rev_options = self.get_url_rev_options(url)
304-
305-
logger.info('Exporting svn repository %s to %s', url, location)
306-
with indent_log():
307-
if os.path.exists(location):
308-
# Subversion doesn't like to check out over an existing
309-
# directory --force fixes this, but was only added in svn 1.5
310-
rmtree(location)
311-
cmd_args = make_command(
312-
'export', self.get_remote_call_options(),
313-
rev_options.to_args(), url, location,
314-
)
315-
self.run_command(cmd_args, show_stdout=False)
316-
317297
def fetch_new(self, dest, url, rev_options):
318298
# type: (str, HiddenText, RevOptions) -> None
319299
rev_display = rev_options.to_display()

src/pip/_internal/vcs/versioncontrol.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,6 @@ def _is_local_repository(cls, repo):
376376
drive, tail = os.path.splitdrive(repo)
377377
return repo.startswith(os.path.sep) or bool(drive)
378378

379-
def export(self, location, url):
380-
# type: (str, HiddenText) -> None
381-
"""
382-
Export the repository at the url to the destination location
383-
i.e. only download the files, without vcs informations
384-
385-
:param url: the repository URL starting with a vcs prefix.
386-
"""
387-
raise NotImplementedError
388-
389379
@classmethod
390380
def get_netloc_and_auth(cls, netloc, scheme):
391381
# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]
@@ -448,8 +438,8 @@ def make_rev_args(username, password):
448438
def get_url_rev_options(self, url):
449439
# type: (HiddenText) -> Tuple[HiddenText, RevOptions]
450440
"""
451-
Return the URL and RevOptions object to use in obtain() and in
452-
some cases export(), as a tuple (url, rev_options).
441+
Return the URL and RevOptions object to use in obtain(),
442+
as a tuple (url, rev_options).
453443
"""
454444
secret_url, rev, user_pass = self.get_url_rev_and_auth(url.secret)
455445
username, secret_password = user_pass

tests/functional/test_vcs_bazaar.py

+1-50
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,9 @@
66

77
import pytest
88

9-
from pip._internal.utils.misc import hide_url
109
from pip._internal.vcs.bazaar import Bazaar
1110
from pip._internal.vcs.versioncontrol import RemoteNotFoundError
12-
from tests.lib import (
13-
_test_path_to_file_url,
14-
_vcs_add,
15-
create_file,
16-
is_bzr_installed,
17-
need_bzr,
18-
)
11+
from tests.lib import is_bzr_installed, need_bzr
1912

2013

2114
@pytest.mark.skipif(
@@ -26,48 +19,6 @@ def test_ensure_bzr_available():
2619
assert is_bzr_installed()
2720

2821

29-
@need_bzr
30-
def test_export(script, tmpdir):
31-
"""Test that a Bazaar branch can be exported."""
32-
source_dir = tmpdir / 'test-source'
33-
source_dir.mkdir()
34-
35-
create_file(source_dir / 'test_file', 'something')
36-
37-
_vcs_add(script, str(source_dir), vcs='bazaar')
38-
39-
export_dir = str(tmpdir / 'export')
40-
url = hide_url('bzr+' + _test_path_to_file_url(source_dir))
41-
Bazaar().export(export_dir, url=url)
42-
43-
assert os.listdir(export_dir) == ['test_file']
44-
45-
46-
@need_bzr
47-
def test_export_rev(script, tmpdir):
48-
"""Test that a Bazaar branch can be exported, specifying a rev."""
49-
source_dir = tmpdir / 'test-source'
50-
source_dir.mkdir()
51-
52-
# Create a single file that is changed by two revisions.
53-
create_file(source_dir / 'test_file', 'something initial')
54-
_vcs_add(script, str(source_dir), vcs='bazaar')
55-
56-
create_file(source_dir / 'test_file', 'something new')
57-
script.run(
58-
'bzr', 'commit', '-q',
59-
'--author', 'pip <[email protected]>',
60-
'-m', 'change test file', cwd=source_dir,
61-
)
62-
63-
export_dir = tmpdir / 'export'
64-
url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
65-
Bazaar().export(str(export_dir), url=url)
66-
67-
with open(export_dir / 'test_file') as f:
68-
assert f.read() == 'something initial'
69-
70-
7122
@need_bzr
7223
def test_get_remote_url__no_remote(script, tmpdir):
7324
repo_dir = tmpdir / 'temp-repo'

tests/unit/test_vcs.py

-8
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,6 @@ def test_obtain(self):
570570
hide_url('http://svn.example.com/'), '/tmp/test',
571571
])
572572

573-
def test_export(self):
574-
self.svn.export(self.dest, hide_url(self.url))
575-
self.assert_call_args([
576-
'svn', 'export', '--non-interactive', '--username', 'username',
577-
'--password', hide_value('password'),
578-
hide_url('http://svn.example.com/'), '/tmp/test',
579-
])
580-
581573
def test_fetch_new(self):
582574
self.svn.fetch_new(self.dest, hide_url(self.url), self.rev_options)
583575
self.assert_call_args([

0 commit comments

Comments
 (0)