~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Aaron Bentley
  • Date: 2005-09-14 21:53:30 UTC
  • mto: (1185.1.29)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: abentley@panoramicfeedback.com-20050914215330-4c93c44266d3169d
Started work on handling missing_for_merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import gzip
28
28
from cStringIO import StringIO
 
29
import os
29
30
import urllib2
 
31
import urlparse
30
32
 
31
33
from bzrlib.errors import BzrError, BzrCheckError
32
 
from bzrlib.branch import Branch, BZR_BRANCH_FORMAT_5
 
34
from bzrlib.branch import Branch, BZR_BRANCH_FORMAT
33
35
from bzrlib.trace import mutter
34
 
from bzrlib.xml5 import serializer_v5
35
 
 
36
 
# velocitynet.com.au transparently proxies connections and thereby
37
 
# breaks keep-alive -- sucks!
 
36
from bzrlib.xml import serializer_v4
38
37
 
39
38
 
40
39
ENABLE_URLGRABBER = False
85
84
    orig_url = url
86
85
    while True:
87
86
        try:
88
 
            ff = get_url(url + '/.bzr/branch-format')
89
 
 
 
87
            fmt_url = url + '/.bzr/branch-format'
 
88
            ff = get_url(fmt_url)
90
89
            fmt = ff.read()
91
90
            ff.close()
92
91
 
93
 
            if fmt != BZR_BRANCH_FORMAT_5:
 
92
            fmt = fmt.rstrip('\r\n')
 
93
            if fmt != BZR_BRANCH_FORMAT.rstrip('\r\n'):
94
94
                raise BzrError("sorry, branch format %r not supported at url %s"
95
95
                               % (fmt, url))
96
96
            
98
98
        except urllib2.URLError:
99
99
            pass
100
100
 
101
 
        try:
102
 
            idx = url.rindex('/')
103
 
        except ValueError:
104
 
            raise BzrError('no branch root found for URL %s' % orig_url)
105
 
 
106
 
        url = url[:idx]        
 
101
        scheme, host, path = list(urlparse.urlparse(url))[:3]
 
102
        # discard params, query, fragment
 
103
        
 
104
        # strip off one component of the path component
 
105
        idx = path.rfind('/')
 
106
        if idx == -1 or path == '/':
 
107
            raise BzrError('no branch root found for URL %s'
 
108
                           ' or enclosing directories'
 
109
                           % orig_url)
 
110
        path = path[:idx]
 
111
        url = urlparse.urlunparse((scheme, host, path, '', '', ''))
107
112
        
108
113
 
109
114
 
154
159
 
155
160
 
156
161
    def get_revision(self, revision_id):
157
 
        from bzrlib.revision import Revision
158
162
        try:
159
163
            revf = self.revision_store[revision_id]
160
164
        except KeyError:
161
165
            raise NoSuchRevision(self, revision_id)
162
 
        r = serializer_v5.read_revision(revf)
 
166
        r = serializer_v4.read_revision(revf)
163
167
        if r.revision_id != revision_id:
164
168
            raise BzrCheckError('revision stored as {%s} actually contains {%s}'
165
169
                                % (revision_id, r.revision_id))
180
184
        p = self._path(fileid)
181
185
        try:
182
186
            return get_url(p, compressed=True)
183
 
        except:
 
187
        except urllib2.URLError:
184
188
            raise KeyError(fileid)
185
189
    
186
190