changeset 41001:21ffe6b97a25

context: error out if basefilectx.cmp() is called without self._filenode The base implementation can't handle such cases because the filelog has no knowledge about the working directory. Loading self._filenode should have no extra cost since self.size() would load it anyway.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 16 Dec 2018 16:31:31 +0900
parents 39953bcf1f51
children 1de3364320af
files mercurial/context.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sun Dec 16 16:24:45 2018 +0900
+++ b/mercurial/context.py	Sun Dec 16 16:31:31 2018 +0900
@@ -702,6 +702,10 @@
         if fctx._customcmp:
             return fctx.cmp(self)
 
+        if self._filenode is None:
+            raise error.ProgrammingError(
+                'filectx.cmp() must be reimplemented if not backed by revlog')
+
         if fctx._filenode is None:
             if self._repo._encodefilterpats:
                 # can't rely on size() because wdir content may be decoded