Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 31751:2133437dad17
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.
author | Jun Wu <quark@fb.com> |
---|---|
date | Thu, 30 Mar 2017 15:34:08 -0700 |
parents | f319981c24c9 |
children | f424fb180fea |
comparison
equal
deleted
inserted
replaced
31750:f319981c24c9 | 31751:2133437dad17 |
---|---|
1265 cachedrev = None | 1265 cachedrev = None |
1266 if node == nullid: | 1266 if node == nullid: |
1267 return "" | 1267 return "" |
1268 if self._cache: | 1268 if self._cache: |
1269 if self._cache[0] == node: | 1269 if self._cache[0] == node: |
1270 return self._cache[2] | 1270 # _cache only stores rawtext |
1271 if raw: | |
1272 return self._cache[2] | |
1271 cachedrev = self._cache[1] | 1273 cachedrev = self._cache[1] |
1272 | 1274 |
1273 # look up what we need to read | 1275 # look up what we need to read |
1274 rawtext = None | 1276 rawtext = None |
1275 if rev is None: | 1277 if rev is None: |
1292 text, validatehash = self._processflags(rawtext, self.flags(rev), | 1294 text, validatehash = self._processflags(rawtext, self.flags(rev), |
1293 'read', raw=raw) | 1295 'read', raw=raw) |
1294 if validatehash: | 1296 if validatehash: |
1295 self.checkhash(text, node, rev=rev) | 1297 self.checkhash(text, node, rev=rev) |
1296 | 1298 |
1297 self._cache = (node, rev, text) | 1299 self._cache = (node, rev, rawtext) |
1298 return text | 1300 return text |
1299 | 1301 |
1300 def hash(self, text, p1, p2): | 1302 def hash(self, text, p1, p2): |
1301 """Compute a node hash. | 1303 """Compute a node hash. |
1302 | 1304 |