# HG changeset patch # User Yuya Nishihara # Date 2018-12-16 07:24:45 # Node ID 39953bcf1f51dedfd4e4950b25917c449b18048b # Parent e10adebf8176584ec05fc229471b54ffa93bdd11 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. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -702,14 +702,20 @@ class basefilectx(object): if fctx._customcmp: return fctx.cmp(self) - if (fctx._filenode 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()): + if fctx._filenode is None: + if self._repo._encodefilterpats: + # can't rely on size() because wdir content may be decoded + return self._filelog.cmp(self._filenode, fctx.data()) + if self.size() - 4 == fctx.size(): + # size() can match: + # if file data starts with '\1\n', empty metadata block is + # prepended, which adds 4 bytes to filelog.size(). + return self._filelog.cmp(self._filenode, fctx.data()) + if self.size() == fctx.size(): + # size() matches: need to compare content return self._filelog.cmp(self._filenode, fctx.data()) + # size() differs return True def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None):