~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remotebranch.py

  • Committer: Lalo Martins
  • Date: 2005-09-09 11:37:44 UTC
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050909113744-22f870db25a9e5f5
getting rid of everything that calls the Branch constructor directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
1
3
# Copyright (C) 2005 Canonical Ltd
2
4
 
3
5
# This program is free software; you can redistribute it and/or modify
26
28
from cStringIO import StringIO
27
29
import os
28
30
import urllib2
29
 
import urlparse
30
31
 
31
32
from bzrlib.errors import BzrError, BzrCheckError
32
33
from bzrlib.branch import Branch, BZR_BRANCH_FORMAT
82
83
    orig_url = url
83
84
    while True:
84
85
        try:
85
 
            fmt_url = url + '/.bzr/branch-format'
86
 
            ff = get_url(fmt_url)
 
86
            ff = get_url(url + '/.bzr/branch-format')
 
87
 
87
88
            fmt = ff.read()
88
89
            ff.close()
89
90
 
96
97
        except urllib2.URLError:
97
98
            pass
98
99
 
99
 
        scheme, host, path = list(urlparse.urlparse(url))[:3]
100
 
        # discard params, query, fragment
101
 
        
102
 
        # strip off one component of the path component
103
 
        idx = path.rfind('/')
104
 
        if idx == -1 or path == '/':
105
 
            raise BzrError('no branch root found for URL %s'
106
 
                           ' or enclosing directories'
107
 
                           % orig_url)
108
 
        path = path[:idx]
109
 
        url = urlparse.urlunparse((scheme, host, path, '', '', ''))
110
 
        
 
100
        try:
 
101
            idx = url.rindex('/')
 
102
        except ValueError:
 
103
            raise BzrError('no branch root found for URL %s' % orig_url)
 
104
 
 
105
        url = url[:idx]        
111
106
 
112
107
 
113
108
class RemoteBranch(Branch):
182
177
        p = self._path(fileid)
183
178
        try:
184
179
            return get_url(p, compressed=True)
185
 
        except urllib2.URLError:
 
180
        except:
186
181
            raise KeyError(fileid)
187
182
    
188
183