~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2010-11-24 16:01:57 UTC
  • mfrom: (4597.13.7 cleanup)
  • mto: This revision was merged to the branch mainline in revision 5558.
  • Revision ID: v.ladeuil+lp@free.fr-20101124160157-kieuslo7wj9abdmb
Merge cleanup into 638451-malformed

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
        config_id = self.config_id()
497
497
        for (section_name, section) in sections:
498
498
            for (name, value) in section.iteritems():
499
 
                yield (name, value, section_name, config_id)
 
499
                yield (name, parser._quote(value), section_name,
 
500
                       config_id, parser)
500
501
 
501
502
    def _get_option_policy(self, section, option_name):
502
503
        """Return the policy for the given (section, option_name) pair."""
1042
1043
        config_id = self.config_id()
1043
1044
        for (section_name, section) in sections:
1044
1045
            for (name, value) in section.iteritems():
1045
 
                yield (name, value, section_name, config_id)
 
1046
                yield (name, value, section_name,
 
1047
                       config_id, branch_config._get_parser())
1046
1048
        # Then the global options
1047
1049
        for option in self._get_global_config()._get_options():
1048
1050
            yield option
1862
1864
        for c in self._get_configs(directory, scope):
1863
1865
            if displayed:
1864
1866
                break
1865
 
            for (oname, value, section, conf_id) in c._get_options():
 
1867
            for (oname, value, section, conf_id, parser) in c._get_options():
1866
1868
                if name == oname:
1867
1869
                    # Display only the first value and exit
1868
 
                    self.outf.write('%s\n' % (value))
 
1870
 
 
1871
                    # FIXME: We need to use get_user_option to take policies
 
1872
                    # into account and we need to make sure the option exists
 
1873
                    # too (hence the two for loops), this needs a better API
 
1874
                    # -- vila 20101117
 
1875
                    value = c.get_user_option(name)
 
1876
                    # Quote the value appropriately
 
1877
                    value = parser._quote(value)
 
1878
                    self.outf.write('%s\n' % (value,))
1869
1879
                    displayed = True
1870
1880
                    break
1871
1881
        if not displayed:
1877
1887
        # avoid the delay introduced by the lazy regexp.
1878
1888
        name._compile_and_collapse()
1879
1889
        cur_conf_id = None
 
1890
        cur_section = None
1880
1891
        for c in self._get_configs(directory, scope):
1881
 
            for (oname, value, section, conf_id) in c._get_options():
 
1892
            for (oname, value, section, conf_id, parser) in c._get_options():
1882
1893
                if name.search(oname):
1883
1894
                    if cur_conf_id != conf_id:
1884
1895
                        # Explain where the options are defined
1885
1896
                        self.outf.write('%s:\n' % (conf_id,))
1886
1897
                        cur_conf_id = conf_id
 
1898
                        cur_section = None
 
1899
                    if (section not in (None, 'DEFAULT')
 
1900
                        and cur_section != section):
 
1901
                        # Display the section if it's not the default (or only)
 
1902
                        # one.
 
1903
                        self.outf.write('  [%s]\n' % (section,))
 
1904
                        cur_section = section
1887
1905
                    self.outf.write('  %s = %s\n' % (oname, value))
1888
1906
 
1889
1907
    def _set_config_option(self, name, value, directory, scope):