changeset 44712:a825bfbf6642

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.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 15 Apr 2020 23:11:55 +0900
parents 637eb7f7559b
children 97c10b157665
files mercurial/templatekw.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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: