Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 32981:88b3a38d39e3
config: use the new '_unset' value for 'configlist'
This should let 'configlist' delegate all special processing of the default
config value to the main 'config' method.
The default config value ([]) is still handled in this method.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 12:54:04 +0200 |
parents | 0bf986cfa82b |
children | 6599b7372387 |
comparison
equal
deleted
inserted
replaced
32980:0bf986cfa82b | 32981:88b3a38d39e3 |
---|---|
629 return util.sizetoint(value) | 629 return util.sizetoint(value) |
630 except error.ParseError: | 630 except error.ParseError: |
631 raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')") | 631 raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')") |
632 % (section, name, value)) | 632 % (section, name, value)) |
633 | 633 |
634 def configlist(self, section, name, default=None, untrusted=False): | 634 def configlist(self, section, name, default=_unset, untrusted=False): |
635 """parse a configuration element as a list of comma/space separated | 635 """parse a configuration element as a list of comma/space separated |
636 strings | 636 strings |
637 | 637 |
638 >>> u = ui(); s = 'foo' | 638 >>> u = ui(); s = 'foo' |
639 >>> u.setconfig(s, 'list1', 'this,is "a small" ,test') | 639 >>> u.setconfig(s, 'list1', 'this,is "a small" ,test') |
640 >>> u.configlist(s, 'list1') | 640 >>> u.configlist(s, 'list1') |
641 ['this', 'is', 'a small', 'test'] | 641 ['this', 'is', 'a small', 'test'] |
642 """ | 642 """ |
643 # default is not always a list | 643 # default is not always a list |
644 if isinstance(default, bytes): | 644 v = self.configwith(config.parselist, section, name, default, |
645 default = config.parselist(default) | |
646 return self.configwith(config.parselist, section, name, default or [], | |
647 'list', untrusted) | 645 'list', untrusted) |
646 if isinstance(v, bytes): | |
647 return config.parselist(v) | |
648 elif v is None: | |
649 return [] | |
650 return v | |
648 | 651 |
649 def configdate(self, section, name, default=None, untrusted=False): | 652 def configdate(self, section, name, default=None, untrusted=False): |
650 """parse a configuration element as a tuple of ints | 653 """parse a configuration element as a tuple of ints |
651 | 654 |
652 >>> u = ui(); s = 'foo' | 655 >>> u = ui(); s = 'foo' |