changeset 14854:23c2d7d25329

eol: eol.only-consistent can now be specified in .hgeol
author Stepan Koltsov <stepancheg@yandex-team.ru>
date Fri, 01 Jul 2011 22:53:58 +0400
parents 4731d61cd36b
children f33579435378
files hgext/eol.py tests/test-eol.t
diffstat 2 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/eol.py	Thu Jul 07 10:34:19 2011 +0200
+++ b/hgext/eol.py	Fri Jul 01 22:53:58 2011 +0400
@@ -158,7 +158,7 @@
         # about inconsistent newlines.
         self.match = match.match(root, '', [], include, exclude)
 
-    def setfilters(self, ui):
+    def copytoui(self, ui):
         for pattern, style in self.cfg.items('patterns'):
             key = style.upper()
             try:
@@ -167,6 +167,9 @@
             except KeyError:
                 ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
                         % (style, self.cfg.source('patterns', pattern)))
+        # eol.only-consistent can be specified in ~/.hgrc or .hgeol
+        for k, v in self.cfg.items('eol'):
+            ui.setconfig('eol', k, v)
 
     def checkrev(self, repo, ctx, files):
         failed = []
@@ -273,7 +276,7 @@
             eol = parseeol(self.ui, self, nodes)
             if eol is None:
                 return None
-            eol.setfilters(self.ui)
+            eol.copytoui(self.ui)
             return eol.match
 
         def _hgcleardirstate(self):
--- a/tests/test-eol.t	Thu Jul 07 10:34:19 2011 +0200
+++ b/tests/test-eol.t	Fri Jul 01 22:53:58 2011 +0400
@@ -441,3 +441,25 @@
   warning: ignoring .hgeol file due to parse error at .hgeol:1: bad
   $ hg status
   ? .hgeol.orig
+
+Test eol.only-consistent can be specified in .hgeol
+
+  $ cd $TESTTMP
+  $ hg init only-consistent
+  $ cd only-consistent
+  $ printf "first\nsecond\r\n" > a.txt
+  $ hg add a.txt
+  $ cat > .hgeol << EOF
+  > [eol]
+  > only-consistent = True
+  > EOF
+  $ hg commit -m 'inconsistent'
+  abort: inconsistent newline style in a.txt
+  
+  [255]
+  $ cat > .hgeol << EOF
+  > [eol]
+  > only-consistent = False
+  > EOF
+  $ hg commit -m 'consistent'
+