comparison mercurial/context.py @ 40990:39953bcf1f51

context: collapse complex condition to see if filelog have to be compared It's hard to read. I'd rather make the return statement duplicated.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 16 Dec 2018 16:24:45 +0900
parents e10adebf8176
children 21ffe6b97a25
comparison
equal deleted inserted replaced
40989:e10adebf8176 40990:39953bcf1f51
700 returns True if different than fctx. 700 returns True if different than fctx.
701 """ 701 """
702 if fctx._customcmp: 702 if fctx._customcmp:
703 return fctx.cmp(self) 703 return fctx.cmp(self)
704 704
705 if (fctx._filenode is None 705 if fctx._filenode is None:
706 and (self._repo._encodefilterpats 706 if self._repo._encodefilterpats:
707 # if file data starts with '\1\n', empty metadata block is 707 # can't rely on size() because wdir content may be decoded
708 # prepended, which adds 4 bytes to filelog.size(). 708 return self._filelog.cmp(self._filenode, fctx.data())
709 or self.size() - 4 == fctx.size()) 709 if self.size() - 4 == fctx.size():
710 or self.size() == fctx.size()): 710 # size() can match:
711 # if file data starts with '\1\n', empty metadata block is
712 # prepended, which adds 4 bytes to filelog.size().
713 return self._filelog.cmp(self._filenode, fctx.data())
714 if self.size() == fctx.size():
715 # size() matches: need to compare content
711 return self._filelog.cmp(self._filenode, fctx.data()) 716 return self._filelog.cmp(self._filenode, fctx.data())
712 717
718 # size() differs
713 return True 719 return True
714 720
715 def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None): 721 def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None):
716 """return the first ancestor of <srcrev> introducing <fnode> 722 """return the first ancestor of <srcrev> introducing <fnode>
717 723