~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-25 00:53:47 UTC
  • mfrom: (1878.1.3 config-urls-53653)
  • Revision ID: pqm@pqm.ubuntu.com-20060725005347-58e24243afe3e03f
(jam) Update LocationConfig to support local paths again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
from StringIO import StringIO
71
71
 
72
72
import bzrlib
73
 
import bzrlib.errors as errors
 
73
from bzrlib import errors, urlutils
74
74
from bzrlib.osutils import pathjoin
75
75
from bzrlib.trace import mutter, warning
76
76
import bzrlib.util.configobj.configobj as configobj
367
367
                        ' to ~/.bazaar/locations.conf')
368
368
            name_generator = branches_config_filename
369
369
        super(LocationConfig, self).__init__(name_generator)
 
370
        # local file locations are looked up by local path, rather than
 
371
        # by file url. This is because the config file is a user
 
372
        # file, and we would rather not expose the user to file urls.
 
373
        if location.startswith('file://'):
 
374
            location = urlutils.local_path_from_url(location)
370
375
        self.location = location
371
376
 
372
377
    def _get_section(self):
382
387
            del location_names[-1]
383
388
        matches=[]
384
389
        for section in sections:
385
 
            section_names = section.split('/')
 
390
            # location is a local path if possible, so we need
 
391
            # to convert 'file://' urls to local paths if necessary.
 
392
            # This also avoids having file:///path be a more exact
 
393
            # match than '/path'.
 
394
            if section.startswith('file://'):
 
395
                section_path = urlutils.local_path_from_url(section)
 
396
            else:
 
397
                section_path = section
 
398
            section_names = section_path.split('/')
386
399
            if section.endswith('/'):
387
400
                del section_names[-1]
388
401
            names = zip(location_names, section_names)