[PATCH 1 of 4] context: add isbinary function
Laurens Holst
laurens.nospam at grauw.nl
Tue Dec 27 15:31:03 CST 2011
# HG changeset patch
# User Laurens Holst <laurens.hg at grauw.nl>
# Date 1324488015 -3600
# Node ID 3317d5c34f384c6d1d8440e19980a2261beecc7a
# Parent 3bcfea777efc41c87918c1bb594615ff4fb6a34b
context: add isbinary function
diff -r 3bcfea777efc -r 3317d5c34f38 mercurial/context.py
--- a/mercurial/context.py Sat Dec 24 00:52:06 2011 +0900
+++ 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
diff -r 3bcfea777efc -r 3317d5c34f38 mercurial/filemerge.py
--- a/mercurial/filemerge.py Sat Dec 24 00:52:06 2011 +0900
+++ 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" %
More information about the Mercurial-devel
mailing list