# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1586959915 -32400
#      Wed Apr 15 23:11:55 2020 +0900
# Node ID 5b857d88bc5e391ff928ac253c42248784527b4e
# Parent  f9735a7cf54beb15dd252042df17cb620556b103
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:
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to