Patchwork [1,of,7] develwarn: move config gating inside the develwarn function

login
register
mail settings
Submitter Pierre-Yves David
Date May 5, 2016, 5:05 p.m.
Message ID <4e60a6b778f63b58e628.1462467951@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/14927/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Pierre-Yves David - May 5, 2016, 5:05 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1462456668 -7200
#      Thu May 05 15:57:48 2016 +0200
# Node ID 4e60a6b778f63b58e62849999d70660c8d29cf8f
# Parent  e0e72d67a8cd370218453ca0444e02aadabd56a8
# EXP-Topic develwarn
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).
Yuya Nishihara - May 6, 2016, 3:25 a.m.
On Thu, 05 May 2016 19:05:51 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1462456668 -7200
> #      Thu May 05 15:57:48 2016 +0200
> # Node ID 4e60a6b778f63b58e62849999d70660c8d29cf8f
> # Parent  e0e72d67a8cd370218453ca0444e02aadabd56a8
> # EXP-Topic develwarn
> 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).
> 
> diff -r e0e72d67a8cd -r 4e60a6b778f6 mercurial/ui.py
> --- a/mercurial/ui.py	Sun Apr 17 13:06:44 2016 +0900
> +++ b/mercurial/ui.py	Thu May 05 15:57:48 2016 +0200
> @@ -1135,12 +1135,15 @@ class ui(object):
>          '''
>          return msg
>  
> -    def develwarn(self, msg, stacklevel=1):
> +    def develwarn(self, msg, stacklevel=1, config=None):
>          """issue a developer warning message
>  
>          Use 'stacklevel' to report the offender some layers further up in the
>          stack.
>          """
> +        if not self.configbool('devel', 'all-warnings'):
> +            if config is not None or not self.configbool('devel', config):
> +                return

Perhaps "config is not None 'and' not self.configbool('devel', config)". Other
than that, the series looks good to me.
Pierre-Yves David - May 8, 2016, 8:41 a.m.
Good catch, I fixed that and pushed the series.

On 05/06/2016 05:25 AM, Yuya Nishihara wrote:
> On Thu, 05 May 2016 19:05:51 +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1462456668 -7200
>> #      Thu May 05 15:57:48 2016 +0200
>> # Node ID 4e60a6b778f63b58e62849999d70660c8d29cf8f
>> # Parent  e0e72d67a8cd370218453ca0444e02aadabd56a8
>> # EXP-Topic develwarn
>> 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).
>>
>> diff -r e0e72d67a8cd -r 4e60a6b778f6 mercurial/ui.py
>> --- a/mercurial/ui.py	Sun Apr 17 13:06:44 2016 +0900
>> +++ b/mercurial/ui.py	Thu May 05 15:57:48 2016 +0200
>> @@ -1135,12 +1135,15 @@ class ui(object):
>>           '''
>>           return msg
>>   
>> -    def develwarn(self, msg, stacklevel=1):
>> +    def develwarn(self, msg, stacklevel=1, config=None):
>>           """issue a developer warning message
>>   
>>           Use 'stacklevel' to report the offender some layers further up in the
>>           stack.
>>           """
>> +        if not self.configbool('devel', 'all-warnings'):
>> +            if config is not None or not self.configbool('devel', config):
>> +                return
> Perhaps "config is not None 'and' not self.configbool('devel', config)". Other
> than that, the series looks good to me.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r e0e72d67a8cd -r 4e60a6b778f6 mercurial/ui.py
--- a/mercurial/ui.py	Sun Apr 17 13:06:44 2016 +0900
+++ b/mercurial/ui.py	Thu May 05 15:57:48 2016 +0200
@@ -1135,12 +1135,15 @@  class ui(object):
         '''
         return msg
 
-    def develwarn(self, msg, stacklevel=1):
+    def develwarn(self, msg, stacklevel=1, config=None):
         """issue a developer warning message
 
         Use 'stacklevel' to report the offender some layers further up in the
         stack.
         """
+        if not self.configbool('devel', 'all-warnings'):
+            if config is not None or not self.configbool('devel', config):
+                return
         msg = 'devel-warn: ' + msg
         stacklevel += 1 # get in develwarn
         if self.tracebackflag: