changeset 3241:0d2c095aeb2a

depthcache: issue a progress bar when loading the depth cache The operation can be in the minute order of magnitude of some larger repository. We better keep the user entertain when he wait.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Nov 2017 16:53:29 +0100
parents 9361149224a7
children 55e1ad0d7174
files hgext3rd/evolve/depthcache.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/depthcache.py	Wed Nov 22 15:05:15 2017 +0100
+++ b/hgext3rd/evolve/depthcache.py	Thu Nov 23 16:53:29 2017 +0100
@@ -129,9 +129,18 @@
         """compute the rev of one revision, assert previous revision has an hot cache
         """
         cl = repo.unfiltered().changelog
-        for rev in data:
+        total = len(data)
+
+        def progress(pos, rev):
+            repo.ui.progress('updating depth cache',
+                             pos, 'rev %s' % rev, unit='revision', total=total)
+        progress(0, '')
+        for idx, rev in enumerate(data, 1):
             assert rev == len(self._data), (rev, len(self._data))
             self._data.append(self._depth(cl, rev))
+            if not (idx % 10000): # progress as a too high performance impact
+                progress(idx, rev)
+        progress(None, '')
 
     def _depth(self, changelog, rev):
         cl = changelog