Skip to content

Commit

Permalink
Bazaar: Export directly from the remote branch.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jelmer committed Jan 20, 2019
1 parent 35b1cc1 commit eb7d4b2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ language: python
cache: pip
dist: xenial
python: 3.6
addons:
apt:
packages:
- bzr

stages:
- primary
Expand Down
1 change: 1 addition & 0 deletions news/5443.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid creating an unnecessary local clone of a Bazaar branch when exporting.
13 changes: 5 additions & 8 deletions src/pip/_internal/vcs/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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__)
Expand Down Expand Up @@ -42,13 +41,11 @@ def export(self, location):
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()
Expand Down
25 changes: 25 additions & 0 deletions tests/functional/test_vcs_bazaar.py
Original file line number Diff line number Diff line change
@@ -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']

0 comments on commit eb7d4b2

Please sign in to comment.