/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-09-21 17:08:09 UTC
  • mfrom: (7389 work)
  • mto: This revision was merged to the branch mainline in revision 7390.
  • Revision ID: jelmer@jelmer.uk-20190921170809-ejewbeue585deajo
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()
210
211
        return PermissionDenied(url, message)
211
212
    if message.endswith(' does not appear to be a git repository'):
212
213
        return NotBranchError(url, message)
 
214
    if re.match('(.+) is not a valid repository name',
 
215
                message.splitlines()[0]):
 
216
        return NotBranchError(url, message)
213
217
    m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
214
218
    if m:
215
219
        return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
674
678
        url = urlutils.URL.from_string(transport.external_url())
675
679
        url.user = url.quoted_user = None
676
680
        url.password = url.quoted_password = None
677
 
        super(BzrGitHttpClient, self).__init__(str(url), *args, **kwargs)
 
681
        url = urlutils.split_segment_parameters(str(url))[0]
 
682
        super(BzrGitHttpClient, self).__init__(url, *args, **kwargs)
678
683
 
679
684
    def _http_request(self, url, headers=None, data=None,
680
685
                      allow_compression=False):
689
694
            `redirect_location` properties, and `read` is a consumable read
690
695
            method for the response data.
691
696
        """
692
 
        headers['User-agent'] = user_agent_for_github()
 
697
        if is_github_url(url):
 
698
            headers['User-agent'] = user_agent_for_github()
693
699
        headers["Pragma"] = "no-cache"
694
700
        if allow_compression:
695
701
            headers["Accept-Encoding"] = "gzip"
735
741
        return WrapResponse(response), read
736
742
 
737
743
 
 
744
def _git_url_and_path_from_transport(external_url):
 
745
    url, _ = urlutils.split_segment_parameters(external_url)
 
746
    return urlparse.urlsplit(url)
 
747
 
 
748
 
738
749
class RemoteGitControlDirFormat(GitControlDirFormat):
739
750
    """The .git directory control format."""
740
751
 
761
772
        """Open this directory.
762
773
 
763
774
        """
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]
 
775
        split_url = _git_url_and_path_from_transport(transport.external_url())
769
776
        if isinstance(transport, GitSmartTransport):
770
777
            client = transport._get_client()
771
 
            client_path = transport._get_path()
772
 
        elif scheme in ("http", "https"):
 
778
        elif split_url.scheme in ("http", "https"):
773
779
            client = BzrGitHttpClient(transport)
774
 
            client_path, _ = urlutils.split_segment_parameters(transport._path)
775
 
        elif scheme == 'file':
 
780
        elif split_url.scheme in ('file', ):
776
781
            client = dulwich.client.LocalGitClient()
777
 
            client_path = transport.local_abspath('.')
778
782
        else:
779
783
            raise NotBranchError(transport.base)
780
784
        if not _found:
781
785
            pass  # TODO(jelmer): Actually probe for something
782
 
        return RemoteGitDir(transport, self, client, client_path)
 
786
        return RemoteGitDir(transport, self, client, split_url.path)
783
787
 
784
788
    def get_format_description(self):
785
789
        return "Remote Git Repository"