diff hgext/eol.py @ 14855:f33579435378

eol: fix missing trailing newlines in comitted files Some text editors (Eclipse, for example) do not add trailing newlines, so diffs often contain annoying "\ No newline at the end of file". This patch to eol extension simply adds trailing newline on commit.
author Stepan Koltsov <stepancheg@yandex-team.ru>
date Fri, 01 Jul 2011 23:12:52 +0400
parents 23c2d7d25329
children 9f5cd6b6d758
line wrap: on
line diff
--- a/hgext/eol.py	Fri Jul 01 22:53:58 2011 +0400
+++ b/hgext/eol.py	Fri Jul 01 23:12:52 2011 +0400
@@ -106,6 +106,8 @@
         return s
     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
         return s
+    if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
+        s = s + '\n'
     return eolre.sub('\n', s)
 
 def tocrlf(s, params, ui, **kwargs):
@@ -114,6 +116,8 @@
         return s
     if ui.configbool('eol', 'only-consistent', True) and inconsistenteol(s):
         return s
+    if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
+        s = s + '\n'
     return eolre.sub('\r\n', s)
 
 def isbinary(s, params):