Merge with stable
authorChristian Ebert <blacktrash@gmx.net>
Thu, 10 Apr 2008 01:48:29 +0200
changeset 446 1c3a9f84dbbc
parent 443 3b71ebfe45ac (current diff)
parent 445 0c91995647e9 (diff)
child 451 78796cd3e7d0
Merge with stable
hgkw/keyword.py
--- a/hgkw/keyword.py	Wed Apr 09 09:13:17 2008 +0200
+++ b/hgkw/keyword.py	Thu Apr 10 01:48:29 2008 +0200
@@ -102,11 +102,6 @@
     '''Returns hgdate in cvs-like UTC format.'''
     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
 
-def textsafe(s):
-    '''Safe version of util.binary with reversed logic.
-    Note: argument may not be None, which is allowed for util.binary.'''
-    return '\0' not in s
-
 # make keyword tools accessible
 kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc': ['.hg*']}
 
@@ -165,7 +160,7 @@
 
     def expand(self, path, node, data):
         '''Returns data with keywords expanded.'''
-        if not self.restrict and self.matcher(path) and textsafe(data):
+        if not self.restrict and self.matcher(path) and not util.binary(data):
             changenode = self.getnode(path, node)
             return self.substitute(data, path, changenode, self.re_kw.sub)
         return data
@@ -193,7 +188,7 @@
             for f in candidates:
                 fp = self.repo.file(f)
                 data = fp.read(mf[f])
-                if not textsafe(data):
+                if util.binary(data):
                     continue
                 if expand:
                     changenode = node or self.getnode(f, mf[f])
@@ -213,7 +208,7 @@
 
     def shrink(self, fname, text):
         '''Returns text with all keyword substitutions removed.'''
-        if self.matcher(fname) and textsafe(text):
+        if self.matcher(fname) and not util.binary(text):
             return self.shrinktext(text)
         return text
 
@@ -221,7 +216,7 @@
         '''Returns lines with keyword substitutions removed.'''
         if self.matcher(fname):
             text = ''.join(lines)
-            if textsafe(text):
+            if not util.binary(text):
                 return self.shrinktext(text).splitlines(True)
         return lines