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
|
cache: pip
|
||||||
dist: xenial
|
dist: xenial
|
||||||
python: 3.6
|
python: 3.6
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- bzr
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- primary
|
- 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 (
|
from pip._internal.utils.misc import (
|
||||||
display_path, make_vcs_requirement_url, rmtree,
|
display_path, make_vcs_requirement_url, rmtree,
|
||||||
)
|
)
|
||||||
from pip._internal.utils.temp_dir import TempDirectory
|
|
||||||
from pip._internal.vcs import VersionControl, vcs
|
from pip._internal.vcs import VersionControl, vcs
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -42,13 +41,11 @@ class Bazaar(VersionControl):
|
||||||
if os.path.exists(location):
|
if os.path.exists(location):
|
||||||
rmtree(location)
|
rmtree(location)
|
||||||
|
|
||||||
with TempDirectory(kind="export") as temp_dir:
|
url, rev_options = self.get_url_rev_options(self.url)
|
||||||
self.unpack(temp_dir.path)
|
self.run_command(
|
||||||
|
['export', location, url] + rev_options.to_args(),
|
||||||
self.run_command(
|
show_stdout=False,
|
||||||
['export', location],
|
)
|
||||||
cwd=temp_dir.path, show_stdout=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
def fetch_new(self, dest, url, rev_options):
|
def fetch_new(self, dest, url, rev_options):
|
||||||
rev_display = rev_options.to_display()
|
rev_display = rev_options.to_display()
|
||||||
|
|
|
@ -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