Patchwork [33,of,41] basefilectx: move cmp from filectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 12, 2013, 4:27 p.m.
Message ID <a3fcf44d68e93df30631.1376324849@laptop.local>
Download mbox | patch
Permalink /patch/2159/
State Accepted
Commit ef7c47e4002f31afc516d6d005b28ec4f08ff4b8
Headers show

Comments

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

Patch

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