~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Jelmer Vernooij
  • Date: 2012-07-02 18:21:51 UTC
  • mfrom: (6531 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6535.
  • Revision ID: jelmer@samba.org-20120702182151-zk9utamutjtjhipq
mergeĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
2398
2398
                value = self.default()
2399
2399
                if not isinstance(value, unicode):
2400
2400
                    raise AssertionError(
2401
 
                    'Callable default values should be unicode')
 
2401
                        "Callable default value for '%s' should be unicode"
 
2402
                        % (self.name))
2402
2403
            else:
2403
2404
                value = self.default
2404
2405
        return value
3443
3444
 
3444
3445
class LocationSection(Section):
3445
3446
 
3446
 
    def __init__(self, section, extra_path):
 
3447
    def __init__(self, section, extra_path, branch_name=None):
3447
3448
        super(LocationSection, self).__init__(section.id, section.options)
3448
3449
        self.extra_path = extra_path
 
3450
        if branch_name is None:
 
3451
            branch_name = ''
3449
3452
        self.locals = {'relpath': extra_path,
3450
 
                       'basename': urlutils.basename(extra_path)}
 
3453
                       'basename': urlutils.basename(extra_path),
 
3454
                       'branchname': branch_name}
3451
3455
 
3452
3456
    def get(self, name, default=None, expand=True):
3453
3457
        value = super(LocationSection, self).get(name, default)
3523
3527
 
3524
3528
    def __init__(self, store, location):
3525
3529
        super(LocationMatcher, self).__init__(store)
 
3530
        url, params = urlutils.split_segment_parameters(location)
3526
3531
        if location.startswith('file://'):
3527
3532
            location = urlutils.local_path_from_url(location)
3528
3533
        self.location = location
 
3534
        branch_name = params.get('branch')
 
3535
        if branch_name is None:
 
3536
            self.branch_name = urlutils.basename(self.location)
 
3537
        else:
 
3538
            self.branch_name = urlutils.unescape(branch_name)
3529
3539
 
3530
3540
    def _get_matching_sections(self):
3531
3541
        """Get all sections matching ``location``."""
3557
3567
            while True:
3558
3568
                section = iter_all_sections.next()
3559
3569
                if section_id == section.id:
3560
 
                    matching_sections.append(
3561
 
                        (length, LocationSection(section, extra_path)))
 
3570
                    section = LocationSection(section, extra_path,
 
3571
                                              self.branch_name)
 
3572
                    matching_sections.append((length, section))
3562
3573
                    break
3563
3574
        return matching_sections
3564
3575