~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Martin Pool
  • Date: 2005-05-11 01:06:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050511010607-2475d3b03b3b4b0e
- Use urlgrabber by default

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
At the moment remote branches are only for HTTP and only for read
23
23
access.
24
 
 
25
24
"""
26
25
 
27
26
 
38
37
# breaks keep-alive -- sucks!
39
38
 
40
39
 
41
 
 
42
 
ENABLE_URLGRABBER = False
43
 
 
44
 
def get_url(url, compressed=False):
45
 
    import urllib2
46
 
    if compressed:
47
 
        url += '.gz'
48
 
    mutter("get_url %s" % url)
49
 
    url_f = urllib2.urlopen(url)
50
 
    if compressed:
51
 
        return gzip.GzipFile(fileobj=StringIO(url_f.read()))
52
 
    else:
53
 
        return url_f
 
40
ENABLE_URLGRABBER = True
54
41
 
55
42
 
56
43
if ENABLE_URLGRABBER:
62
49
            url = path
63
50
            if compressed:
64
51
                url += '.gz'
 
52
            mutter("grab url %s" % url)
65
53
            url_f = urlgrabber.urlopen(url, keepalive=1, close_connection=0)
66
54
            if not compressed:
67
55
                return url_f
69
57
                return gzip.GzipFile(fileobj=StringIO(url_f.read()))
70
58
        except urllib2.URLError, e:
71
59
            raise BzrError("remote fetch failed: %r: %s" % (url, e))
 
60
else:
 
61
    def get_url(url, compressed=False):
 
62
        import urllib2
 
63
        if compressed:
 
64
            url += '.gz'
 
65
        mutter("get_url %s" % url)
 
66
        url_f = urllib2.urlopen(url)
 
67
        if compressed:
 
68
            return gzip.GzipFile(fileobj=StringIO(url_f.read()))
 
69
        else:
 
70
            return url_f
72
71
 
73
72
 
74
73