Patchwork [5,of,6] configitems: register 'blackbox.maxsize' as an example of 'configbytes'

login
register
mail settings
Submitter Pierre-Yves David
Date June 22, 2017, 7:34 a.m.
Message ID <dce1d4f988a2866b1043.1498116874@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21602/
State Changes Requested
Headers show

Comments

Pierre-Yves David - June 22, 2017, 7:34 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497698466 -7200
#      Sat Jun 17 13:21:06 2017 +0200
# Node ID dce1d4f988a2866b1043b0b8d360016e32a2d808
# Parent  878499c8ccc070730292887a0c3278de427d756d
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r dce1d4f988a2
configitems: register 'blackbox.maxsize' as an example of 'configbytes'

This exercise the default value handling in 'configbytes'.
Denis Laxalde - June 22, 2017, 12:40 p.m.
Pierre-Yves David a écrit :
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1497698466 -7200
> #      Sat Jun 17 13:21:06 2017 +0200
> # Node ID dce1d4f988a2866b1043b0b8d360016e32a2d808
> # Parent  878499c8ccc070730292887a0c3278de427d756d
> # EXP-Topic config.register
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r dce1d4f988a2
> configitems: register 'blackbox.maxsize' as an example of 'configbytes'

Nit: maybe rephrase the first line as "blackbox: register 'maxsize'
option using configitems" as the patch does not touch configitems.py?

> This exercise the default value handling in 'configbytes'.
>
> diff --git a/hgext/blackbox.py b/hgext/blackbox.py
> --- a/hgext/blackbox.py
> +++ b/hgext/blackbox.py
> @@ -58,6 +58,13 @@ testedwith = 'ships-with-hg-core'
>  cmdtable = {}
>  command = registrar.command(cmdtable)
>
> +configtable = {}
> +configitem = registrar.configitem(configtable)
> +
> +configitem('blackbox', 'maxsize',
> +    default=1048576,
> +)
> +
>  lastui = None
>
>  filehandles = {}
> @@ -120,7 +127,7 @@ def wrapui(ui):
>                                     (newpath, oldpath, err.strerror))
>
>              fp = _openlog(self._bbvfs)
> -            maxsize = self.configbytes('blackbox', 'maxsize', 1048576)
> +            maxsize = self.configbytes('blackbox', 'maxsize')
>              if maxsize > 0:
>                  st = self._bbvfs.fstat(fp)
>                  if st.st_size >= maxsize:
Pierre-Yves David - June 22, 2017, 12:58 p.m.
On 06/22/2017 02:40 PM, Denis Laxalde wrote:
> Pierre-Yves David a écrit :
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1497698466 -7200
>> #      Sat Jun 17 13:21:06 2017 +0200
>> # Node ID dce1d4f988a2866b1043b0b8d360016e32a2d808
>> # Parent  878499c8ccc070730292887a0c3278de427d756d
>> # EXP-Topic config.register
>> # Available At 
>> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull 
>> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 
>> dce1d4f988a2
>> configitems: register 'blackbox.maxsize' as an example of 'configbytes'
> 
> Nit: maybe rephrase the first line as "blackbox: register 'maxsize'
> option using configitems" as the patch does not touch configitems.py?

That leading part is a "topic" not a filename (mercurial has the 
filename information already). In this case, this is part of series 
about configitems so the topic is 'configitems' (as the other one 
registering item).

>> This exercise the default value handling in 'configbytes'.
>>
>> diff --git a/hgext/blackbox.py b/hgext/blackbox.py
>> --- a/hgext/blackbox.py
>> +++ b/hgext/blackbox.py
>> @@ -58,6 +58,13 @@ testedwith = 'ships-with-hg-core'
>>  cmdtable = {}
>>  command = registrar.command(cmdtable)
>>
>> +configtable = {}
>> +configitem = registrar.configitem(configtable)
>> +
>> +configitem('blackbox', 'maxsize',
>> +    default=1048576,
>> +)
>> +
>>  lastui = None
>>
>>  filehandles = {}
>> @@ -120,7 +127,7 @@ def wrapui(ui):
>>                                     (newpath, oldpath, err.strerror))
>>
>>              fp = _openlog(self._bbvfs)
>> -            maxsize = self.configbytes('blackbox', 'maxsize', 1048576)
>> +            maxsize = self.configbytes('blackbox', 'maxsize')
>>              if maxsize > 0:
>>                  st = self._bbvfs.fstat(fp)
>>                  if st.st_size >= maxsize:
>

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -58,6 +58,13 @@  testedwith = 'ships-with-hg-core'
 cmdtable = {}
 command = registrar.command(cmdtable)
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('blackbox', 'maxsize',
+    default=1048576,
+)
+
 lastui = None
 
 filehandles = {}
@@ -120,7 +127,7 @@  def wrapui(ui):
                                    (newpath, oldpath, err.strerror))
 
             fp = _openlog(self._bbvfs)
-            maxsize = self.configbytes('blackbox', 'maxsize', 1048576)
+            maxsize = self.configbytes('blackbox', 'maxsize')
             if maxsize > 0:
                 st = self._bbvfs.fstat(fp)
                 if st.st_size >= maxsize: