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

login
register
mail settings
Submitter Pierre-Yves David
Date June 27, 2017, 1 p.m.
Message ID <7f88de5db210f85d30a4.1498568434@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21773/
State Accepted
Headers show

Comments

Pierre-Yves David - June 27, 2017, 1 p.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 7f88de5db210f85d30a491a16d0117d8b1656643
# Parent  f9a1d0c3ac29bcce9ac9f4c03c1c8e6600ecfa54
# 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 7f88de5db210
configitems: register 'blackbox.maxsize' as an example of 'configbytes'

This exercise the default value handling in 'configbytes'.

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: