28
28
from cStringIO import StringIO
31
from errors import BzrError, BzrCheckError
32
from branch import Branch, BZR_BRANCH_FORMAT
33
from trace import mutter
31
from bzrlib.errors import BzrError, BzrCheckError
32
from bzrlib.branch import Branch, BZR_BRANCH_FORMAT_5
33
from bzrlib.trace import mutter
34
from bzrlib.xml5 import serializer_v5
35
36
# velocitynet.com.au transparently proxies connections and thereby
36
37
# breaks keep-alive -- sucks!
39
ENABLE_URLGRABBER = True
40
ENABLE_URLGRABBER = False
42
from bzrlib.errors import BzrError, NoSuchRevision
44
class GetFailed(BzrError):
45
def __init__(self, url, status):
46
BzrError.__init__(self, "Get %s failed with status %s" % (url, status))
42
50
if ENABLE_URLGRABBER:
44
import urlgrabber.keepalive
45
urlgrabber.keepalive.DEBUG = 0
51
import util.urlgrabber
52
import util.urlgrabber.keepalive
53
util.urlgrabber.keepalive.DEBUG = 0
46
54
def get_url(path, compressed=False):
51
59
mutter("grab url %s" % url)
52
url_f = urlgrabber.urlopen(url, keepalive=1, close_connection=0)
60
url_f = util.urlgrabber.urlopen(url, keepalive=1, close_connection=0)
61
if url_f.status != 200:
62
raise GetFailed(url, url_f.status)
147
156
def get_revision(self, revision_id):
148
157
from bzrlib.revision import Revision
149
from bzrlib.xml import unpack_xml
150
revf = self.revision_store[revision_id]
151
r = unpack_xml(Revision, revf)
159
revf = self.revision_store[revision_id]
161
raise NoSuchRevision(self, revision_id)
162
r = serializer_v5.read_revision(revf)
152
163
if r.revision_id != revision_id:
153
164
raise BzrCheckError('revision stored as {%s} actually contains {%s}'
154
165
% (revision_id, r.revision_id))