/breezy-hg/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy-hg/trunk

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2018-09-29 08:12:07 UTC
  • Revision ID: jelmer@jelmer.uk-20180929081207-ol8c5exqqakpu1l3
Fix a bunch of tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    :param externa_url: External URL for transport
93
93
    :return: Boolean indicating whether transport is backed onto hg
94
94
    """
 
95
    from breezy.transport.http import Request
95
96
    url = external_url.rstrip("/") + "?pairs=%s-%s&cmd=between" % ("0" * 40, "0" * 40)
96
 
    from breezy.transport.http._urllib import HttpTransport_urllib, Request
97
 
    if isinstance(transport, HttpTransport_urllib):
98
 
        req = Request('GET', url, accepted_errors=[200, 403, 404, 405])
99
 
        req.follow_redirections = True
100
 
        resp = transport._perform(req)
101
 
        if resp.code == 404:
102
 
            return False
103
 
        headers = resp.headers
104
 
    else:
105
 
        try:
106
 
            from breezy.transport.http._pycurl import PyCurlTransport
107
 
        except errors.DependencyNotPresent:
108
 
            return False
109
 
        else:
110
 
            import pycurl
111
 
            from cStringIO import StringIO
112
 
            if isinstance(transport, PyCurlTransport):
113
 
                conn = transport._get_curl()
114
 
                conn.setopt(pycurl.URL, url)
115
 
                transport._set_curl_options(conn)
116
 
                conn.setopt(pycurl.HTTPGET, 1)
117
 
                header = StringIO()
118
 
                data = StringIO()
119
 
                conn.setopt(pycurl.FOLLOWLOCATION, 1)
120
 
                conn.setopt(pycurl.HEADERFUNCTION, header.write)
121
 
                conn.setopt(pycurl.WRITEFUNCTION, data.write)
122
 
                transport._curl_perform(conn, header)
123
 
                code = conn.getinfo(pycurl.HTTP_CODE)
124
 
                if code == 404:
125
 
                    return False
126
 
                headers = transport._parse_headers(header)
127
 
            else:
128
 
                return False
 
97
    req = Request('GET', url, accepted_errors=[200, 403, 404, 405])
 
98
    req.follow_redirections = True
 
99
    resp = transport._perform(req)
 
100
    if resp.code == 404:
 
101
        return False
 
102
    headers = resp.headers
129
103
    ct = headers.getheader("Content-Type")
130
104
    if ct is None:
131
105
        return False
186
160
    @classmethod
187
161
    def known_formats(cls):
188
162
        from breezy.plugins.hg.dir import HgControlDirFormat
189
 
        return set([HgControlDirFormat()])
 
163
        return [HgControlDirFormat()]
190
164
 
191
165
 
192
166
ControlDirFormat.register_prober(HgProber)