Patchwork [1,of,3] configitems: register the 'eol.fix-trailing-newline' config

login
register
mail settings
Submitter Boris Feld
Date Sept. 11, 2017, 1:44 p.m.
Message ID <e5c4424dc0dabfa817f4.1505137461@FB>
Download mbox | patch
Permalink /patch/23774/
State Accepted
Headers show

Comments

Boris Feld - Sept. 11, 2017, 1:44 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1498786761 -7200
#      ven. juin 30 03:39:21 2017 +0200
# Node ID e5c4424dc0dabfa817f41fc81a49b4232fda05e6
# Parent  a763c891f36e55f4869f443c220227d1da747d18
# EXP-Topic config.register.eol
configitems: register the 'eol.fix-trailing-newline' config
Yuya Nishihara - Sept. 12, 2017, 2:25 p.m.
On Mon, 11 Sep 2017 15:44:21 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1498786761 -7200
> #      ven. juin 30 03:39:21 2017 +0200
> # Node ID e5c4424dc0dabfa817f41fc81a49b4232fda05e6
> # Parent  a763c891f36e55f4869f443c220227d1da747d18
> # EXP-Topic config.register.eol
> configitems: register the 'eol.fix-trailing-newline' config

Also queued, thanks.

Patch

diff -r a763c891f36e -r e5c4424dc0da hgext/eol.py
--- a/hgext/eol.py	mar. sept. 05 15:18:45 2017 -0700
+++ b/hgext/eol.py	ven. juin 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)