mercurial/context.py
changeset 19604 ef7c47e4002f
parent 19603 a92302f48a56
child 19605 cf7322cb1c13
equal deleted inserted replaced
19603:a92302f48a56 19604:ef7c47e4002f
   521         try:
   521         try:
   522             return util.binary(self.data())
   522             return util.binary(self.data())
   523         except IOError:
   523         except IOError:
   524             return False
   524             return False
   525 
   525 
       
   526     def cmp(self, fctx):
       
   527         """compare with other file context
       
   528 
       
   529         returns True if different than fctx.
       
   530         """
       
   531         if (fctx._filerev is None
       
   532             and (self._repo._encodefilterpats
       
   533                  # if file data starts with '\1\n', empty metadata block is
       
   534                  # prepended, which adds 4 bytes to filelog.size().
       
   535                  or self.size() - 4 == fctx.size())
       
   536             or self.size() == fctx.size()):
       
   537             return self._filelog.cmp(self._filenode, fctx.data())
       
   538 
       
   539         return True
       
   540 
   526 class filectx(basefilectx):
   541 class filectx(basefilectx):
   527     """A filecontext object makes access to data related to a particular
   542     """A filecontext object makes access to data related to a particular
   528        filerevision convenient."""
   543        filerevision convenient."""
   529     def __init__(self, repo, path, changeid=None, fileid=None,
   544     def __init__(self, repo, path, changeid=None, fileid=None,
   530                  filelog=None, changectx=None):
   545                  filelog=None, changectx=None):
   580 
   595 
   581     def data(self):
   596     def data(self):
   582         return self._filelog.read(self._filenode)
   597         return self._filelog.read(self._filenode)
   583     def size(self):
   598     def size(self):
   584         return self._filelog.size(self._filerev)
   599         return self._filelog.size(self._filerev)
   585 
       
   586     def cmp(self, fctx):
       
   587         """compare with other file context
       
   588 
       
   589         returns True if different than fctx.
       
   590         """
       
   591         if (fctx._filerev is None
       
   592             and (self._repo._encodefilterpats
       
   593                  # if file data starts with '\1\n', empty metadata block is
       
   594                  # prepended, which adds 4 bytes to filelog.size().
       
   595                  or self.size() - 4 == fctx.size())
       
   596             or self.size() == fctx.size()):
       
   597             return self._filelog.cmp(self._filenode, fctx.data())
       
   598 
       
   599         return True
       
   600 
   600 
   601     def renamed(self):
   601     def renamed(self):
   602         """check if file was actually renamed in this changeset revision
   602         """check if file was actually renamed in this changeset revision
   603 
   603 
   604         If rename logged in file revision, we report copy for changeset only
   604         If rename logged in file revision, we report copy for changeset only