/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/remote.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:33:45 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7389.
  • Revision ID: jelmer@jelmer.uk-20190811133345-dp9j3c569vxj4l9y
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
from . import (
61
61
    lazy_check_versions,
 
62
    is_github_url,
62
63
    user_agent_for_github,
63
64
    )
64
65
lazy_check_versions()
674
675
        url = urlutils.URL.from_string(transport.external_url())
675
676
        url.user = url.quoted_user = None
676
677
        url.password = url.quoted_password = None
677
 
        super(BzrGitHttpClient, self).__init__(str(url), *args, **kwargs)
 
678
        url = urlutils.split_segment_parameters(str(url))[0]
 
679
        super(BzrGitHttpClient, self).__init__(url, *args, **kwargs)
678
680
 
679
681
    def _http_request(self, url, headers=None, data=None,
680
682
                      allow_compression=False):
689
691
            `redirect_location` properties, and `read` is a consumable read
690
692
            method for the response data.
691
693
        """
692
 
        headers['User-agent'] = user_agent_for_github()
 
694
        if is_github_url(url):
 
695
            headers['User-agent'] = user_agent_for_github()
693
696
        headers["Pragma"] = "no-cache"
694
697
        if allow_compression:
695
698
            headers["Accept-Encoding"] = "gzip"
735
738
        return WrapResponse(response), read
736
739
 
737
740
 
 
741
def _git_url_and_path_from_transport(external_url):
 
742
    url, _ = urlutils.split_segment_parameters(external_url)
 
743
    return urlparse.urlsplit(url)
 
744
 
 
745
 
738
746
class RemoteGitControlDirFormat(GitControlDirFormat):
739
747
    """The .git directory control format."""
740
748
 
761
769
        """Open this directory.
762
770
 
763
771
        """
764
 
        # we dont grok readonly - git isn't integrated with transport.
765
 
        url = transport.base
766
 
        if url.startswith('readonly+'):
767
 
            url = url[len('readonly+'):]
768
 
        scheme = urlparse.urlsplit(transport.external_url())[0]
 
772
        split_url = _git_url_and_path_from_transport(transport.external_url())
769
773
        if isinstance(transport, GitSmartTransport):
770
774
            client = transport._get_client()
771
 
            client_path = transport._get_path()
772
 
        elif scheme in ("http", "https"):
 
775
        elif split_url.scheme in ("http", "https"):
773
776
            client = BzrGitHttpClient(transport)
774
 
            client_path, _ = urlutils.split_segment_parameters(transport._path)
775
 
        elif scheme == 'file':
 
777
        elif split_url.scheme in 'file':
776
778
            client = dulwich.client.LocalGitClient()
777
 
            client_path = transport.local_abspath('.')
778
779
        else:
779
780
            raise NotBranchError(transport.base)
780
781
        if not _found:
781
782
            pass  # TODO(jelmer): Actually probe for something
782
 
        return RemoteGitDir(transport, self, client, client_path)
 
783
        return RemoteGitDir(transport, self, client, split_url.path)
783
784
 
784
785
    def get_format_description(self):
785
786
        return "Remote Git Repository"