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

Denis Laxalde denis at laxalde.org
Thu Jun 22 08:40:13 EDT 2017


Pierre-Yves David a écrit :
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at 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:



More information about the Mercurial-devel mailing list