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:
Jelmer Vernooij 2019-01-06 23:49:16 +00:00
parent 35b1cc1c97
commit eb7d4b2178
No known key found for this signature in database
GPG Key ID: 579C160D4C9E23E8
4 changed files with 35 additions and 8 deletions

View File

@ -2,6 +2,10 @@ language: python
cache: pip
dist: xenial
python: 3.6
addons:
apt:
packages:
- bzr
stages:
- primary

1
news/5443.feature Normal file
View File

@ -0,0 +1 @@
Avoid creating an unnecessary local clone of a Bazaar branch when exporting.

View File

@ -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,13 +41,11 @@ class Bazaar(VersionControl):
if os.path.exists(location):
rmtree(location)
with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path)
self.run_command(
['export', location],
cwd=temp_dir.path, show_stdout=False,
)
url, rev_options = self.get_url_rev_options(self.url)
self.run_command(
['export', location, url] + rev_options.to_args(),
show_stdout=False,
)
def fetch_new(self, dest, url, rev_options):
rev_display = rev_options.to_display()

View File

@ -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']