[PATCH 3 of 3 V2] revlog: avoid applying delta chain on cache hit
Jun Wu
quark at fb.com
Mon Apr 3 01:43:01 UTC 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1491183613 25200
# Sun Apr 02 18:40:13 2017 -0700
# Node ID 8324b03f08a91fd039ee83428b86792374640b89
# Parent e5669675e4f24e98c99165c112fa81db66ff6094
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 8324b03f08a9
revlog: avoid applying delta chain on cache hit
Previously, revlog.revision(raw=False) may try to apply the delta chain
on _cache hit. That happens if flags are non-empty. This patch makes rawtext
reused so delta chain application is avoided.
"_cache" and "rev" are moved a bit to avoid unnecessary assignments.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1269,4 +1269,5 @@ class revlog(object):
cachedrev = None
flags = None
+ rawtext = None
if node == nullid:
return ""
@@ -1284,9 +1285,10 @@ class revlog(object):
if flags == REVIDX_DEFAULT_FLAGS:
return self._cache[2]
+ # rawtext is reusable. need to run flag processor
+ rawtext = self._cache[2]
cachedrev = self._cache[1]
# look up what we need to read
- rawtext = None
if rawtext is None:
if rev is None:
@@ -1306,6 +1308,9 @@ class revlog(object):
rawtext = mdiff.patches(rawtext, bins)
+ self._cache = (node, rev, rawtext)
if flags is None:
+ if rev is None:
+ rev = self.rev(node)
flags = self.flags(rev)
@@ -1314,5 +1319,4 @@ class revlog(object):
self.checkhash(text, node, rev=rev)
- self._cache = (node, rev, rawtext)
return text
More information about the Mercurial-devel
mailing list