changeset 34117:0f685a229a81

configitems: register the 'eol.fix-trailing-newline' config
author Boris Feld <boris.feld@octobus.net>
date Fri, 30 Jun 2017 03:39:21 +0200
parents aeb956e7729f
children 4a6ef3a5b282
files hgext/eol.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/eol.py	Fri Jun 30 03:43:43 2017 +0200
+++ b/hgext/eol.py	Fri Jun 30 03:39:21 2017 +0200
@@ -102,6 +102,7 @@
     extensions,
     match,
     pycompat,
+    registrar,
     util,
 )
 
@@ -111,6 +112,13 @@
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('eol', 'fix-trailing-newline',
+    default=False,
+)
+
 # Matches a lone LF, i.e., one that is not part of CRLF.
 singlelf = re.compile('(^|[^\r])\n')
 
@@ -123,7 +131,7 @@
         return s
     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
         return s
-    if (ui.configbool('eol', 'fix-trailing-newline', False)
+    if (ui.configbool('eol', 'fix-trailing-newline')
         and s and s[-1] != '\n'):
         s = s + '\n'
     return util.tolf(s)
@@ -134,7 +142,7 @@
         return s
     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
         return s
-    if (ui.configbool('eol', 'fix-trailing-newline', False)
+    if (ui.configbool('eol', 'fix-trailing-newline')
         and s and s[-1] != '\n'):
         s = s + '\n'
     return util.tocrlf(s)