~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-02-13 08:15:16 UTC
  • mto: (1534.5.2 bzr-dir)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060213081516-3d13375f0de0ccb6
find_repository sufficiently robust.

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
    def open_containing(url):
283
283
        """Open an existing branch which contains url.
284
284
        
285
 
        This probes for a branch at url, and searches upwards from there.
 
285
        :param url: url to search from.
 
286
        See open_containing_transport for more detail.
 
287
        """
 
288
        return BzrDir.open_containing_transport(get_transport(url))
 
289
    
 
290
    @staticmethod
 
291
    def open_containing_transport(a_transport):
 
292
        """Open an existing branch which contains a_transport.base
 
293
 
 
294
        This probes for a branch at a_transport, and searches upwards from there.
286
295
 
287
296
        Basically we keep looking up until we find the control directory or
288
297
        run into the root.  If there isn't one, raises NotBranchError.
290
299
        format, UnknownFormatError or UnsupportedFormatError are raised.
291
300
        If there is one, it is returned, along with the unused portion of url.
292
301
        """
293
 
        t = get_transport(url)
294
302
        # this gets the normalised url back. I.e. '.' -> the full path.
295
 
        url = t.base
 
303
        url = a_transport.base
296
304
        while True:
297
305
            try:
298
 
                format = BzrDirFormat.find_format(t)
299
 
                return format.open(t), t.relpath(url)
 
306
                format = BzrDirFormat.find_format(a_transport)
 
307
                return format.open(a_transport), a_transport.relpath(url)
300
308
            except errors.NotBranchError, e:
301
 
                mutter('not a branch in: %r %s', t.base, e)
302
 
            new_t = t.clone('..')
303
 
            if new_t.base == t.base:
 
309
                mutter('not a branch in: %r %s', a_transport.base, e)
 
310
            new_t = a_transport.clone('..')
 
311
            if new_t.base == a_transport.base:
304
312
                # reached the root, whatever that may be
305
313
                raise errors.NotBranchError(path=url)
306
 
            t = new_t
 
314
            a_transport = new_t
307
315
 
308
316
    def open_repository(self, _unsupported=False):
309
317
        """Open the repository object at this BzrDir if one is present.