diff mercurial/context.py @ 15848:012b285cf643 stable

filectx: fix cmp() of file starting with '\1\n' If file data starts with '\1\n', it will be escaped in the revlog to create an empty metadata block, thus adding four bytes to the size in the revlog size index. There's no way to detect that this has happened in filelog.size() faster than decompressing each revision [1]. For filectx.cmp(), we have the size of the file in the working directory available. If it differs by exactly four bytes, it may be this case, so do a full comparison. [1]: http://markmail.org/message/5akdbmmqx7vq2fsg
author Yuya Nishihara <yuya@tcha.org>
date Thu, 12 Jan 2012 00:49:45 +0900
parents cf5f9df6406b
children e5feebc1f3bb a3e2b9a1f063
line wrap: on
line diff
--- a/mercurial/context.py	Wed Jan 11 09:26:47 2012 -0600
+++ b/mercurial/context.py	Thu Jan 12 00:49:45 2012 +0900
@@ -368,7 +368,11 @@
 
         returns True if different than fctx.
         """
-        if (fctx._filerev is None and self._repo._encodefilterpats
+        if (fctx._filerev is None
+            and (self._repo._encodefilterpats
+                 # if file data starts with '\1\n', empty metadata block is
+                 # prepended, which adds 4 bytes to fielog.size().
+                 or self.size() - 4 == fctx.size())
             or self.size() == fctx.size()):
             return self._filelog.cmp(self._filenode, fctx.data())