changeset 6248:b4fca699c33d

Automated merge with http://hg.intevation.org/mercurial/crew
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 13 Mar 2008 19:53:02 -0700
parents 35bf9c23e17a (current diff) 7f4257b5cbfc (diff)
children cf1fa60fdaf4
files
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/win32text.py	Fri Mar 14 01:39:15 2008 +0100
+++ b/hgext/win32text.py	Thu Mar 13 19:53:02 2008 -0700
@@ -22,6 +22,7 @@
 # [hooks]
 # pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
 
+from mercurial import util
 from mercurial.i18n import gettext as _
 from mercurial.node import bin, short
 import re
@@ -46,19 +47,15 @@
 def dumbencode(s, cmd):
     return s.replace('\r\n', '\n')
 
-def clevertest(s, cmd):
-    if '\0' in s: return False
-    return True
-
 def cleverdecode(s, cmd, **kwargs):
-    if clevertest(s, cmd):
-        return dumbdecode(s, cmd, **kwargs)
-    return s
+    if util.binary(s):
+        return s
+    return dumbdecode(s, cmd, **kwargs)
 
 def cleverencode(s, cmd):
-    if clevertest(s, cmd):
-        return dumbencode(s, cmd)
-    return s
+    if util.binary(s):
+        return s
+    return dumbencode(s, cmd)
 
 _filters = {
     'dumbdecode:': dumbdecode,
@@ -75,7 +72,7 @@
             if f not in c:
                 continue
             data = c[f].data()
-            if '\0' not in data and '\r\n' in data:
+            if not util.binary(data) and '\r\n' in data:
                 if not halt:
                     ui.warn(_('Attempt to commit or push text file(s) '
                               'using CRLF line endings\n'))