[PATCH 33 of 41] basefilectx: move cmp from filectx

Sean Farley sean.michael.farley at gmail.com
Mon Aug 12 11:27:29 CDT 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1376279813 18000
#      Sun Aug 11 22:56:53 2013 -0500
# Node ID a3fcf44d68e93df30631dddd50fb5ec93dc64aeb
# Parent  5d700e27ed06b22b10c187ab6b9804381b51f0d2
basefilectx: move cmp from filectx

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -521,10 +521,25 @@
         try:
             return util.binary(self.data())
         except IOError:
             return False
 
+    def cmp(self, fctx):
+        """compare with other file 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._filelog.cmp(self._filenode, fctx.data())
+
+        return True
+
 class filectx(basefilectx):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
     def __init__(self, repo, path, changeid=None, fileid=None,
                  filelog=None, changectx=None):
@@ -581,25 +596,10 @@
     def data(self):
         return self._filelog.read(self._filenode)
     def size(self):
         return self._filelog.size(self._filerev)
 
-    def cmp(self, fctx):
-        """compare with other file 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._filelog.cmp(self._filenode, fctx.data())
-
-        return True
-
     def renamed(self):
         """check if file was actually renamed in this changeset revision
 
         If rename logged in file revision, we report copy for changeset only
         if file revisions linkrev points back to the changeset in question


More information about the Mercurial-devel mailing list