##// END OF EJS Templates
configitems: register the 'eol.fix-trailing-newline' config
Boris Feld -
r34119:0f685a22 default
parent child Browse files
Show More
@@ -102,6 +102,7 b' from mercurial import ('
102 102 extensions,
103 103 match,
104 104 pycompat,
105 registrar,
105 106 util,
106 107 )
107 108
@@ -111,6 +112,13 b' from mercurial import ('
111 112 # leave the attribute unspecified.
112 113 testedwith = 'ships-with-hg-core'
113 114
115 configtable = {}
116 configitem = registrar.configitem(configtable)
117
118 configitem('eol', 'fix-trailing-newline',
119 default=False,
120 )
121
114 122 # Matches a lone LF, i.e., one that is not part of CRLF.
115 123 singlelf = re.compile('(^|[^\r])\n')
116 124
@@ -123,7 +131,7 b' def tolf(s, params, ui, **kwargs):'
123 131 return s
124 132 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
125 133 return s
126 if (ui.configbool('eol', 'fix-trailing-newline', False)
134 if (ui.configbool('eol', 'fix-trailing-newline')
127 135 and s and s[-1] != '\n'):
128 136 s = s + '\n'
129 137 return util.tolf(s)
@@ -134,7 +142,7 b' def tocrlf(s, params, ui, **kwargs):'
134 142 return s
135 143 if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
136 144 return s
137 if (ui.configbool('eol', 'fix-trailing-newline', False)
145 if (ui.configbool('eol', 'fix-trailing-newline')
138 146 and s and s[-1] != '\n'):
139 147 s = s + '\n'
140 148 return util.tocrlf(s)
General Comments 0
You need to be logged in to leave comments. Login now