# HG changeset patch
# User Boris Feld <boris.f...@octobus.net>
# Date 1499523976 -7200
#      Sat Jul 08 16:26:16 2017 +0200
# Node ID 774ff18cc36b72822f598b4fa5a51628513926e3
# Parent  5d3e659c979aa428ba44b138cfac30b7cca28fb3
# EXP-Topic obs-cache
cache: adds debug details about what the content of the update

Having more data in debug is good, we add a small method to help providing them.

diff -r 5d3e659c979a -r 774ff18cc36b mercurial/cache.py
--- a/mercurial/cache.py        Fri Jul 07 22:22:39 2017 +0200
+++ b/mercurial/cache.py        Sat Jul 08 16:26:16 2017 +0200
@@ -91,6 +91,11 @@
         """
         raise NotImplementedError
 
+    @abc.abstractmethod
+    def _updatesummary(self, data):
+        """return a small string to be included in debug output"""
+        raise NotImplementedError
+
     # Useful "public" function (no need to override them)
 
     def update(self, repo):
@@ -114,8 +119,9 @@
         starttime = util.timer()
         self._updatefrom(repo, data)
         duration = util.timer() - starttime
-        repo.ui.log('cache', 'updated %s in %.4f seconds\n',
-                    self._cachename, duration)
+        summary = self._updatesummary(data)
+        repo.ui.log('cache', 'updated %s in %.4f seconds (%s)\n',
+                    self._cachename, duration, summary)
 
         self._cachekey = newkey
 
@@ -165,6 +171,9 @@
     def _fetchupdatedata(self, repo):
         return self._fetchchangelogdata(self._cachekey, repo.changelog)
 
+    def _updatesummary(self, data):
+        return '%ir' % len(data)
+
 class obsstoresourcebase(incrementalcachebase):
     """an abstract class for cache that source data from the obsstore
 
@@ -182,6 +191,9 @@
     def _fetchupdatedata(self, repo):
         return repo.obsstore.getmarkerssince(self._cachekey)
 
+    def _updatesummary(self, data):
+        return '%io' % len(data)
+
 class dualsourcecache(obsstoresourcebase, changelogsourcebase):
     """An abstract class for cache that needs both changelog and obsstore
 
@@ -216,3 +228,6 @@
         newkey = newclkey + newobskey
         data = (revs, obsmarkers)
         return reset, data, newkey
+
+    def _updatesummary(self, data):
+        return '%ir, %io' % (len(data[0]), len(data[1]))
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to