~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Martin Pool
  • Date: 2005-09-05 09:27:11 UTC
  • Revision ID: mbp@sourcefrog.net-20050905092711-f9f5bded3fd82605
- more disentangling of xml storage format from objects

- remove pack_xml and unpack_xml function in favor of 
  serializer object

- test unpacking canned revision xml

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
# breaks keep-alive -- sucks!
37
37
 
38
38
 
39
 
ENABLE_URLGRABBER = True
 
39
ENABLE_URLGRABBER = False
40
40
 
41
 
from bzrlib.errors import BzrError
 
41
from bzrlib.errors import BzrError, NoSuchRevision
42
42
 
43
43
class GetFailed(BzrError):
44
44
    def __init__(self, url, status):
47
47
        self.status = status
48
48
 
49
49
if ENABLE_URLGRABBER:
50
 
    import urlgrabber
51
 
    import urlgrabber.keepalive
52
 
    urlgrabber.keepalive.DEBUG = 0
 
50
    import util.urlgrabber
 
51
    import util.urlgrabber.keepalive
 
52
    util.urlgrabber.keepalive.DEBUG = 0
53
53
    def get_url(path, compressed=False):
54
54
        try:
55
55
            url = path
56
56
            if compressed:
57
57
                url += '.gz'
58
58
            mutter("grab url %s" % url)
59
 
            url_f = urlgrabber.urlopen(url, keepalive=1, close_connection=0)
 
59
            url_f = util.urlgrabber.urlopen(url, keepalive=1, close_connection=0)
60
60
            if url_f.status != 200:
61
61
                raise GetFailed(url, url_f.status)
62
62
            if not compressed:
155
155
 
156
156
    def get_revision(self, revision_id):
157
157
        from bzrlib.revision import Revision
158
 
        from bzrlib.xml import unpack_xml
159
 
        revf = self.revision_store[revision_id]
160
 
        r = unpack_xml(Revision, revf)
 
158
        try:
 
159
            revf = self.revision_store[revision_id]
 
160
        except KeyError:
 
161
            raise NoSuchRevision(self, revision_id)
 
162
        r = serializer_v4.read_revision(revf)
161
163
        if r.revision_id != revision_id:
162
164
            raise BzrCheckError('revision stored as {%s} actually contains {%s}'
163
165
                                % (revision_id, r.revision_id))