# HG changeset patch # User Yuya Nishihara # Date 2020-04-15 14:11:55 # Node ID a825bfbf66429e63b46f5d91ec5bd725b68e098d # Parent 637eb7f7559b03734c989948fe7395cb44d5a9de templatekw: cache mergestate even if merge is not ongoing While playing with eBPF, I noticed .hg/merge/state{,2} files were tried to open() for each revision. That's not healthy. Let's cache the "inactive" state as well. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -417,13 +417,15 @@ def getgraphnodecurrent(repo, ctx, cache if ctx.node() in wpnodes: return b'@' else: - merge_nodes = cache.get(b'merge_nodes', ()) - if not merge_nodes: + merge_nodes = cache.get(b'merge_nodes') + if merge_nodes is None: from . import merge mergestate = merge.mergestate.read(repo) if mergestate.active(): merge_nodes = (mergestate.local, mergestate.other) + else: + merge_nodes = () cache[b'merge_nodes'] = merge_nodes if ctx.node() in merge_nodes: