hgext/eol.py
changeset 16683 525fdb738975
parent 16273 12e3f93b1cbc
child 16743 38caf405d010
equal deleted inserted replaced
16676:654b9e1966f7 16683:525fdb738975
   109     """Filter to convert to LF EOLs."""
   109     """Filter to convert to LF EOLs."""
   110     if util.binary(s):
   110     if util.binary(s):
   111         return s
   111         return s
   112     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
   112     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
   113         return s
   113         return s
   114     if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
   114     if (ui.configbool('eol', 'fix-trailing-newline', False)
       
   115         and s and s[-1] != '\n'):
   115         s = s + '\n'
   116         s = s + '\n'
   116     return eolre.sub('\n', s)
   117     return eolre.sub('\n', s)
   117 
   118 
   118 def tocrlf(s, params, ui, **kwargs):
   119 def tocrlf(s, params, ui, **kwargs):
   119     """Filter to convert to CRLF EOLs."""
   120     """Filter to convert to CRLF EOLs."""
   120     if util.binary(s):
   121     if util.binary(s):
   121         return s
   122         return s
   122     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
   123     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
   123         return s
   124         return s
   124     if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
   125     if (ui.configbool('eol', 'fix-trailing-newline', False)
       
   126         and s and s[-1] != '\n'):
   125         s = s + '\n'
   127         s = s + '\n'
   126     return eolre.sub('\r\n', s)
   128     return eolre.sub('\r\n', s)
   127 
   129 
   128 def isbinary(s, params):
   130 def isbinary(s, params):
   129     """Filter to do nothing with the file."""
   131     """Filter to do nothing with the file."""