Skip to content

Remove now unused VCS export code #9713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions src/pip/_internal/vcs/bazaar.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
import os
from typing import List, Optional, Tuple

from pip._internal.utils.misc import HiddenText, display_path, rmtree
from pip._internal.utils.misc import HiddenText, display_path
from pip._internal.utils.subprocess import make_command
from pip._internal.utils.urls import path_to_url
from pip._internal.vcs.versioncontrol import (
Expand Down Expand Up @@ -30,21 +29,6 @@ def get_base_rev_args(rev):
# type: (str) -> List[str]
return ['-r', rev]

def export(self, location, url):
# type: (str, HiddenText) -> None
"""
Export the Bazaar repository at the url to the destination location
"""
# Remove the location to make sure Bazaar can export it correctly
if os.path.exists(location):
rmtree(location)

url, rev_options = self.get_url_rev_options(url)
self.run_command(
make_command('export', location, url, rev_options.to_args()),
show_stdout=False,
)

def fetch_new(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
rev_display = rev_options.to_display()
Expand Down
14 changes: 0 additions & 14 deletions src/pip/_internal/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pip._internal.exceptions import BadCommand, InstallationError
from pip._internal.utils.misc import HiddenText, display_path, hide_url
from pip._internal.utils.subprocess import make_command
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.vcs.versioncontrol import (
AuthInfo,
RemoteNotFoundError,
Expand Down Expand Up @@ -112,19 +111,6 @@ def get_current_branch(cls, location):

return None

def export(self, location, url):
# type: (str, HiddenText) -> None
"""Export the Git repository at the url to the destination location"""
if not location.endswith('/'):
location = location + '/'

with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path, url=url)
self.run_command(
['checkout-index', '-a', '-f', '--prefix', location],
show_stdout=False, cwd=temp_dir.path
)

@classmethod
def get_revision_sha(cls, dest, rev):
# type: (str, str) -> Tuple[Optional[str], bool]
Expand Down
11 changes: 0 additions & 11 deletions src/pip/_internal/vcs/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pip._internal.exceptions import BadCommand, InstallationError
from pip._internal.utils.misc import HiddenText, display_path
from pip._internal.utils.subprocess import make_command
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.urls import path_to_url
from pip._internal.vcs.versioncontrol import (
RevOptions,
Expand All @@ -31,16 +30,6 @@ def get_base_rev_args(rev):
# type: (str) -> List[str]
return [rev]

def export(self, location, url):
# type: (str, HiddenText) -> None
"""Export the Hg repository at the url to the destination location"""
with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path, url=url)

self.run_command(
['archive', location], show_stdout=False, cwd=temp_dir.path
)

def fetch_new(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
rev_display = rev_options.to_display()
Expand Down
20 changes: 0 additions & 20 deletions src/pip/_internal/vcs/subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import re
from typing import List, Optional, Tuple

from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
HiddenText,
display_path,
is_console_interactive,
rmtree,
split_auth_from_netloc,
)
from pip._internal.utils.subprocess import CommandArgs, make_command
Expand Down Expand Up @@ -272,7 +270,6 @@ def get_remote_call_options(self):
in this class.

- checkout
- export
- switch
- update

Expand All @@ -297,23 +294,6 @@ def get_remote_call_options(self):

return []

def export(self, location, url):
# type: (str, HiddenText) -> None
"""Export the svn repository at the url to the destination location"""
url, rev_options = self.get_url_rev_options(url)

logger.info('Exporting svn repository %s to %s', url, location)
with indent_log():
if os.path.exists(location):
# Subversion doesn't like to check out over an existing
# directory --force fixes this, but was only added in svn 1.5
rmtree(location)
cmd_args = make_command(
'export', self.get_remote_call_options(),
rev_options.to_args(), url, location,
)
self.run_command(cmd_args, show_stdout=False)

def fetch_new(self, dest, url, rev_options):
# type: (str, HiddenText, RevOptions) -> None
rev_display = rev_options.to_display()
Expand Down
14 changes: 2 additions & 12 deletions src/pip/_internal/vcs/versioncontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,6 @@ def _is_local_repository(cls, repo):
drive, tail = os.path.splitdrive(repo)
return repo.startswith(os.path.sep) or bool(drive)

def export(self, location, url):
# type: (str, HiddenText) -> None
"""
Export the repository at the url to the destination location
i.e. only download the files, without vcs informations

:param url: the repository URL starting with a vcs prefix.
"""
raise NotImplementedError

@classmethod
def get_netloc_and_auth(cls, netloc, scheme):
# type: (str, str) -> Tuple[str, Tuple[Optional[str], Optional[str]]]
Expand Down Expand Up @@ -448,8 +438,8 @@ def make_rev_args(username, password):
def get_url_rev_options(self, url):
# type: (HiddenText) -> Tuple[HiddenText, RevOptions]
"""
Return the URL and RevOptions object to use in obtain() and in
some cases export(), as a tuple (url, rev_options).
Return the URL and RevOptions object to use in obtain(),
as a tuple (url, rev_options).
"""
secret_url, rev, user_pass = self.get_url_rev_and_auth(url.secret)
username, secret_password = user_pass
Expand Down
51 changes: 1 addition & 50 deletions tests/functional/test_vcs_bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@

import pytest

from pip._internal.utils.misc import hide_url
from pip._internal.vcs.bazaar import Bazaar
from pip._internal.vcs.versioncontrol import RemoteNotFoundError
from tests.lib import (
_test_path_to_file_url,
_vcs_add,
create_file,
is_bzr_installed,
need_bzr,
)
from tests.lib import is_bzr_installed, need_bzr


@pytest.mark.skipif(
Expand All @@ -26,48 +19,6 @@ def test_ensure_bzr_available():
assert is_bzr_installed()


@need_bzr
def test_export(script, tmpdir):
"""Test that a Bazaar branch can be exported."""
source_dir = tmpdir / 'test-source'
source_dir.mkdir()

create_file(source_dir / 'test_file', 'something')

_vcs_add(script, str(source_dir), vcs='bazaar')

export_dir = str(tmpdir / 'export')
url = hide_url('bzr+' + _test_path_to_file_url(source_dir))
Bazaar().export(export_dir, url=url)

assert os.listdir(export_dir) == ['test_file']


@need_bzr
def test_export_rev(script, tmpdir):
"""Test that a Bazaar branch can be exported, specifying a rev."""
source_dir = tmpdir / 'test-source'
source_dir.mkdir()

# Create a single file that is changed by two revisions.
create_file(source_dir / 'test_file', 'something initial')
_vcs_add(script, str(source_dir), vcs='bazaar')

create_file(source_dir / 'test_file', 'something new')
script.run(
'bzr', 'commit', '-q',
'--author', 'pip <[email protected]>',
'-m', 'change test file', cwd=source_dir,
)

export_dir = tmpdir / 'export'
url = hide_url('bzr+' + _test_path_to_file_url(source_dir) + '@1')
Bazaar().export(str(export_dir), url=url)

with open(export_dir / 'test_file') as f:
assert f.read() == 'something initial'


@need_bzr
def test_get_remote_url__no_remote(script, tmpdir):
repo_dir = tmpdir / 'temp-repo'
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,6 @@ def test_obtain(self):
hide_url('http://svn.example.com/'), '/tmp/test',
])

def test_export(self):
self.svn.export(self.dest, hide_url(self.url))
self.assert_call_args([
'svn', 'export', '--non-interactive', '--username', 'username',
'--password', hide_value('password'),
hide_url('http://svn.example.com/'), '/tmp/test',
])

def test_fetch_new(self):
self.svn.fetch_new(self.dest, hide_url(self.url), self.rev_options)
self.assert_call_args([
Expand Down