# HG changeset patch # User Jun Wu # Date 1490913248 25200 # Node ID 2133437dad174cabab4c23a937d550e04b2f9424 # Parent f319981c24c95d7a1019f7c8a49cbc50afa7c35c revlog: fix _cache usage in revision() As documented at revlog.__init__, revlog._cache stores raw text. The current read and write usage of "_cache" in revlog.revision lacks of raw=True check. This patch fixes that by adding check about raw, and storing rawtext explicitly in _cache. Note: it may slow down cache hit code path when raw=False and flags=0. That performance issue will be fixed in a later patch. test-revlog-raw now points us to a new problem. diff -r f319981c24c9 -r 2133437dad17 mercurial/revlog.py --- a/mercurial/revlog.py Thu Mar 30 14:56:09 2017 -0700 +++ b/mercurial/revlog.py Thu Mar 30 15:34:08 2017 -0700 @@ -1267,7 +1267,9 @@ return "" if self._cache: if self._cache[0] == node: - return self._cache[2] + # _cache only stores rawtext + if raw: + return self._cache[2] cachedrev = self._cache[1] # look up what we need to read @@ -1294,7 +1296,7 @@ if validatehash: self.checkhash(text, node, rev=rev) - self._cache = (node, rev, text) + self._cache = (node, rev, rawtext) return text def hash(self, text, p1, p2): diff -r f319981c24c9 -r 2133437dad17 tests/test-revlog-raw.py.out --- a/tests/test-revlog-raw.py.out Thu Mar 30 14:56:09 2017 -0700 +++ b/tests/test-revlog-raw.py.out Thu Mar 30 15:34:08 2017 -0700 @@ -1,1 +1,1 @@ -abort: rev 5: wrong text +abort: crashed: integrity check failed on _testrevlog.i:11