diff mercurial/revlogutils/nodemap.py @ 44788:6493f0a567c2

nodemap: add a new mode option, with an optional "warn" value When "warn" is set, user will get notified when the slow code, used for compatibility is used. This can help people to detect situation were using that feature will give them a slowdown instead of a speedup. Differential Revision: https://phab.mercurial-scm.org/D8414
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 14 Apr 2020 02:45:05 +0200
parents b4537125eb3c
children 6b01799e9db0
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Sun Apr 05 18:32:46 2020 +0200
+++ b/mercurial/revlogutils/nodemap.py	Tue Apr 14 02:45:05 2020 +0200
@@ -13,6 +13,8 @@
 import re
 import struct
 
+from ..i18n import _
+
 from .. import (
     error,
     node as nodemod,
@@ -105,6 +107,9 @@
     def addabort(self, *args, **kwargs):
         pass
 
+    def _report(self, *args):
+        pass
+
 
 def update_persistent_nodemap(revlog):
     """update the persistent nodemap right now
@@ -138,6 +143,11 @@
     ondisk_docket = revlog._nodemap_docket
     feed_data = util.safehasattr(revlog.index, "update_nodemap_data")
     use_mmap = revlog.opener.options.get(b"exp-persistent-nodemap.mmap")
+    mode = revlog.opener.options.get(b"exp-persistent-nodemap.mode")
+    if not can_incremental:
+        msg = _(b"persistent nodemap in strict mode without efficient method")
+        if mode == b'warn':
+            tr._report(b"%s\n" % msg)
 
     data = None
     # first attemp an incremental update of the data