comparison mercurial/ui.py @ 29095:3f33831a9202

develwarn: move config gating inside the develwarn function The config gating is almost always the same and contributor tend to forget it. We move the logic inside the function. Call site will be updated in later changeset. We might make the sub config mandatory in the future (once all old call sites are gone).
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sun, 08 May 2016 10:43:41 +0200
parents 77de985d7c91
children 33a10e212b80
comparison
equal deleted inserted replaced
29088:983353035cec 29095:3f33831a9202
1133 ui.write(s, 'label') is equivalent to 1133 ui.write(s, 'label') is equivalent to
1134 ui.write(ui.label(s, 'label')). 1134 ui.write(ui.label(s, 'label')).
1135 ''' 1135 '''
1136 return msg 1136 return msg
1137 1137
1138 def develwarn(self, msg, stacklevel=1): 1138 def develwarn(self, msg, stacklevel=1, config=None):
1139 """issue a developer warning message 1139 """issue a developer warning message
1140 1140
1141 Use 'stacklevel' to report the offender some layers further up in the 1141 Use 'stacklevel' to report the offender some layers further up in the
1142 stack. 1142 stack.
1143 """ 1143 """
1144 if not self.configbool('devel', 'all-warnings'):
1145 if config is not None and not self.configbool('devel', config):
1146 return
1144 msg = 'devel-warn: ' + msg 1147 msg = 'devel-warn: ' + msg
1145 stacklevel += 1 # get in develwarn 1148 stacklevel += 1 # get in develwarn
1146 if self.tracebackflag: 1149 if self.tracebackflag:
1147 util.debugstacktrace(msg, stacklevel, self.ferr, self.fout) 1150 util.debugstacktrace(msg, stacklevel, self.ferr, self.fout)
1148 self.log('develwarn', '%s at:\n%s' % 1151 self.log('develwarn', '%s at:\n%s' %