depthcache: issue a progress bar when loading the depth cache
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 Nov 2017 16:53:29 +0100
changeset 3241 0d2c095aeb2a
parent 3240 9361149224a7
child 3242 55e1ad0d7174
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.
hgext3rd/evolve/depthcache.py
--- 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