configitems: register 'blackbox.maxsize' as an example of 'configbytes'
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 17 Jun 2017 13:21:06 +0200
changeset 33135 0a638f37f2d2
parent 33134 7dc090faa8a4
child 33136 59c135bb31bc
configitems: register 'blackbox.maxsize' as an example of 'configbytes' This exercise the default value handling in 'configbytes'.
hgext/blackbox.py
--- a/hgext/blackbox.py	Sat Jun 17 13:41:28 2017 +0200
+++ b/hgext/blackbox.py	Sat Jun 17 13:21:06 2017 +0200
@@ -58,6 +58,13 @@
 cmdtable = {}
 command = registrar.command(cmdtable)
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('blackbox', 'maxsize',
+    default=1048576,
+)
+
 lastui = None
 
 filehandles = {}
@@ -120,7 +127,7 @@
                                    (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: