~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: 2010-11-18 20:45:40 UTC
  • mfrom: (5533.2.5 672382-list-values)
  • Revision ID: pqm@pqm.ubuntu.com-20101118204540-un6e3t40melfjp9v
(vila) ``bzr config`` properly displays list values (Vincent Ladeuil)

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
 
1870
 
1868
1871
                    # FIXME: We need to use get_user_option to take policies
1869
1872
                    # into account and we need to make sure the option exists
1870
 
                    # too (hence the two for loops), this needs a better API --
1871
 
                    # vila 20101117
1872
 
                    self.outf.write('%s\n' % c.get_user_option(name))
 
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,))
1873
1879
                    displayed = True
1874
1880
                    break
1875
1881
        if not displayed:
1883
1889
        cur_conf_id = None
1884
1890
        cur_section = None
1885
1891
        for c in self._get_configs(directory, scope):
1886
 
            for (oname, value, section, conf_id) in c._get_options():
 
1892
            for (oname, value, section, conf_id, parser) in c._get_options():
1887
1893
                if name.search(oname):
1888
1894
                    if cur_conf_id != conf_id:
1889
1895
                        # Explain where the options are defined
1894
1900
                        and cur_section != section):
1895
1901
                        # Display the section if it's not the default (or only)
1896
1902
                        # one.
1897
 
                        self.outf.write('  [%s]\n' % section)
 
1903
                        self.outf.write('  [%s]\n' % (section,))
1898
1904
                        cur_section = section
1899
1905
                    self.outf.write('  %s = %s\n' % (oname, value))
1900
1906