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.
--- a/mercurial/templatekw.py Wed Apr 15 19:24:21 2020 +0900
+++ b/mercurial/templatekw.py Wed Apr 15 23:11:55 2020 +0900
@@ -417,13 +417,15 @@
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: