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

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 16, 2018, 8:24 a.m.
Message ID <9143ecd26b985bc6a8d4.1544948662@mimosa>
Download mbox | patch
Permalink /patch/37204/
State New
Headers show

Comments

Yuya Nishihara - Dec. 16, 2018, 8:24 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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