context: add isbinary function
authorLaurens Holst <laurens.hg@grauw.nl>
Wed, 21 Dec 2011 18:20:15 +0100
changeset 15738 e86dd8dfdea0
parent 15737 8edd9f2c7b57
child 15739 be55285470cf
context: add isbinary function
mercurial/context.py
mercurial/filemerge.py
--- a/mercurial/context.py	Tue Dec 27 21:12:09 2011 +0100
+++ b/mercurial/context.py	Wed Dec 21 18:20:15 2011 +0100
@@ -372,6 +372,12 @@
     def size(self):
         return self._filelog.size(self._filerev)
 
+    def isbinary(self):
+        try:
+            return util.binary(self.data())
+        except IOError:
+            return False
+
     def cmp(self, fctx):
         """compare with other file context
 
--- a/mercurial/filemerge.py	Tue Dec 27 21:12:09 2011 +0100
+++ b/mercurial/filemerge.py	Wed Dec 21 18:20:15 2011 +0100
@@ -142,18 +142,12 @@
         f.close()
         return name
 
-    def isbin(ctx):
-        try:
-            return util.binary(ctx.data())
-        except IOError:
-            return False
-
     if not fco.cmp(fcd): # files identical?
         return None
 
     ui = repo.ui
     fd = fcd.path()
-    binary = isbin(fcd) or isbin(fco) or isbin(fca)
+    binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
     symlink = 'l' in fcd.flags() + fco.flags()
     tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
     ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %