Show More
@@ -102,6 +102,7 b' from mercurial import (' | |||||
102 | extensions, |
|
102 | extensions, | |
103 | match, |
|
103 | match, | |
104 | pycompat, |
|
104 | pycompat, | |
|
105 | registrar, | |||
105 | util, |
|
106 | util, | |
106 | ) |
|
107 | ) | |
107 |
|
108 | |||
@@ -111,6 +112,13 b' from mercurial import (' | |||||
111 | # leave the attribute unspecified. |
|
112 | # leave the attribute unspecified. | |
112 | testedwith = 'ships-with-hg-core' |
|
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 | # Matches a lone LF, i.e., one that is not part of CRLF. |
|
122 | # Matches a lone LF, i.e., one that is not part of CRLF. | |
115 | singlelf = re.compile('(^|[^\r])\n') |
|
123 | singlelf = re.compile('(^|[^\r])\n') | |
116 |
|
124 | |||
@@ -123,7 +131,7 b' def tolf(s, params, ui, **kwargs):' | |||||
123 | return s |
|
131 | return s | |
124 | if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s): |
|
132 | if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s): | |
125 | return s |
|
133 | return s | |
126 |
if (ui.configbool('eol', 'fix-trailing-newline' |
|
134 | if (ui.configbool('eol', 'fix-trailing-newline') | |
127 | and s and s[-1] != '\n'): |
|
135 | and s and s[-1] != '\n'): | |
128 | s = s + '\n' |
|
136 | s = s + '\n' | |
129 | return util.tolf(s) |
|
137 | return util.tolf(s) | |
@@ -134,7 +142,7 b' def tocrlf(s, params, ui, **kwargs):' | |||||
134 | return s |
|
142 | return s | |
135 | if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s): |
|
143 | if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s): | |
136 | return s |
|
144 | return s | |
137 |
if (ui.configbool('eol', 'fix-trailing-newline' |
|
145 | if (ui.configbool('eol', 'fix-trailing-newline') | |
138 | and s and s[-1] != '\n'): |
|
146 | and s and s[-1] != '\n'): | |
139 | s = s + '\n' |
|
147 | s = s + '\n' | |
140 | return util.tocrlf(s) |
|
148 | return util.tocrlf(s) |
General Comments 0
You need to be logged in to leave comments.
Login now