mirror of https://github.com/pypa/pip
Bazaar: Export directly from the remote branch.
This significantly improves performance, since it allows the remote server to directly stream a tarball that just contains the requested revision rather than the full repository contents.
This commit is contained in:
parent
35b1cc1c97
commit
eb7d4b2178
|
@ -2,6 +2,10 @@ language: python
|
|||
cache: pip
|
||||
dist: xenial
|
||||
python: 3.6
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- bzr
|
||||
|
||||
stages:
|
||||
- primary
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Avoid creating an unnecessary local clone of a Bazaar branch when exporting.
|
|
@ -9,7 +9,6 @@ from pip._internal.download import path_to_url
|
|||
from pip._internal.utils.misc import (
|
||||
display_path, make_vcs_requirement_url, rmtree,
|
||||
)
|
||||
from pip._internal.utils.temp_dir import TempDirectory
|
||||
from pip._internal.vcs import VersionControl, vcs
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -42,12 +41,10 @@ class Bazaar(VersionControl):
|
|||
if os.path.exists(location):
|
||||
rmtree(location)
|
||||
|
||||
with TempDirectory(kind="export") as temp_dir:
|
||||
self.unpack(temp_dir.path)
|
||||
|
||||
url, rev_options = self.get_url_rev_options(self.url)
|
||||
self.run_command(
|
||||
['export', location],
|
||||
cwd=temp_dir.path, show_stdout=False,
|
||||
['export', location, url] + rev_options.to_args(),
|
||||
show_stdout=False,
|
||||
)
|
||||
|
||||
def fetch_new(self, dest, url, rev_options):
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
"""
|
||||
Contains functional tests of the Bazaar class.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from pip._internal.vcs.bazaar import Bazaar
|
||||
from tests.lib import _test_path_to_file_url, _vcs_add, create_file, need_bzr
|
||||
|
||||
|
||||
@need_bzr
|
||||
def test_export(script, tmpdir):
|
||||
"""Test that a Bazaar branch can be exported."""
|
||||
branch_path = tmpdir / 'test-branch'
|
||||
branch_path.mkdir()
|
||||
|
||||
create_file(branch_path / 'test_file', 'something')
|
||||
|
||||
_vcs_add(script, str(branch_path), vcs='bazaar')
|
||||
|
||||
bzr = Bazaar('bzr+' + _test_path_to_file_url(branch_path))
|
||||
export_dir = str(tmpdir / 'export')
|
||||
bzr.export(export_dir)
|
||||
|
||||
assert os.listdir(export_dir) == ['test_file']
|
Loading…
Reference in New Issue