comparison mercurial/ui.py @ 10455:40dfd46d098f

ui: add HGPLAIN environment variable for easier scripting If HGPLAIN is set, the following settings are ignored when read from hgrc files: - ui.debug - ui.fallbackencoding - ui.quiet - ui.traceback - ui.verbose - defaults.* Localization is also disabled. Equivalent options set via command line are honored.
author Brodie Rao <me+hg@dackz.net>
date Sun, 07 Feb 2010 14:56:18 +0100
parents 5a3a916aad58
children 42afde35e9f7
comparison
equal deleted inserted replaced
10454:37b735d27347 10455:40dfd46d098f
77 except error.ConfigError, inst: 77 except error.ConfigError, inst:
78 if trusted: 78 if trusted:
79 raise 79 raise
80 self.warn(_("Ignored: %s\n") % str(inst)) 80 self.warn(_("Ignored: %s\n") % str(inst))
81 81
82 if self.plain():
83 for k in ('debug', 'fallbackencoding', 'quiet', 'traceback',
84 'verbose'):
85 if k in cfg['ui']:
86 del cfg['ui'][k]
87 for k, v in cfg.items('defaults'):
88 del cfg['defaults'][k]
89
82 if trusted: 90 if trusted:
83 self._tcfg.update(cfg) 91 self._tcfg.update(cfg)
84 self._tcfg.update(self._ocfg) 92 self._tcfg.update(self._ocfg)
85 self._ucfg.update(cfg) 93 self._ucfg.update(cfg)
86 self._ucfg.update(self._ocfg) 94 self._ucfg.update(self._ocfg)
166 def walkconfig(self, untrusted=False): 174 def walkconfig(self, untrusted=False):
167 cfg = self._data(untrusted) 175 cfg = self._data(untrusted)
168 for section in cfg.sections(): 176 for section in cfg.sections():
169 for name, value in self.configitems(section, untrusted): 177 for name, value in self.configitems(section, untrusted):
170 yield section, name, str(value).replace('\n', '\\n') 178 yield section, name, str(value).replace('\n', '\\n')
179
180 def plain(self):
181 return 'HGPLAIN' in os.environ
171 182
172 def username(self): 183 def username(self):
173 """Return default username to be used in commits. 184 """Return default username to be used in commits.
174 185
175 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL 186 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL