[PATCH 11 of 14 RFC] memfilectx: add cmp method
Sean Farley
sean.michael.farley at gmail.com
Tue Jul 9 21:54:42 UTC 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1373323864 18000
# Mon Jul 08 17:51:04 2013 -0500
# Node ID 1fa8870e0ae8dc5f23f5326470c5fbc93f63a95b
# Parent 15c72f9d02eada7a9811034da42628f30bfd073a
memfilectx: add cmp method
This is directly copied from the filectx with the only change being to call the
"self.data() != fctx.data()" directly instead of going through the filelog. Is
there a better way to do this compare?
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1380,5 +1380,20 @@
return 'x' in self._flags
def islink(self):
return 'l' in self._flags
def renamed(self):
return self._copied
+
+ def cmp(self, fctx):
+ """compare with other file context or workingfile context
+
+ returns True if different than fctx.
+ """
+ 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 filelog.size().
+ or self.size() - 4 == fctx.size())
+ or self.size() == fctx.size()):
+ return self.data() != fctx.data()
+
+ return True
More information about the Mercurial-devel
mailing list