[PATCH 3 of 3] context: error out if basefilectx.cmp() is called without self._filenode

Yuya Nishihara yuya at tcha.org
Sun Dec 16 03:24:22 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1544945491 -32400
#      Sun Dec 16 16:31:31 2018 +0900
# Node ID 9143ecd26b985bc6a8d4d2dad5d30f2de0a2d3a7
# Parent  913fdd3fccc6c99def4b1ac8cd60abba1f7aa81d
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.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -702,6 +702,10 @@ class basefilectx(object):
         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


More information about the Mercurial-devel mailing list