debugbuildannotatecache: use progress helper
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 Dec 2018 15:57:11 -0800
changeset 53603 901f6ef670ca5e1a9ed07f31aed4e1930982688d
parent 53602 64051af155963de2a527d4013ad281dbd6ef8d15
child 53604 dd1006874a5aa49f03955f438fbab7effddecfbf
push id1079
push usergszorc@mozilla.com
push dateMon, 10 Dec 2018 19:44:59 +0000
debugbuildannotatecache: use progress helper Differential Revision: https://phab.mercurial-scm.org/D5373
hgext/fastannotate/commands.py
--- a/hgext/fastannotate/commands.py
+++ b/hgext/fastannotate/commands.py
@@ -256,18 +256,19 @@ def debugbuildannotatecache(ui, repo, *p
     paths = list(ctx.walk(m))
     if util.safehasattr(repo, 'prefetchfastannotate'):
         # client
         if opts.get('REV'):
             raise error.Abort(_('--rev cannot be used for client'))
         repo.prefetchfastannotate(paths)
     else:
         # server, or full repo
+        progress = ui.makeprogress(_('building'), total=len(paths))
         for i, path in enumerate(paths):
-            ui.progress(_('building'), i, total=len(paths))
+            progress.update(i)
             with facontext.annotatecontext(repo, path) as actx:
                 try:
                     if actx.isuptodate(rev):
                         continue
                     actx.annotate(rev, rev)
                 except (faerror.CannotReuseError, faerror.CorruptedFileError):
                     # the cache is broken (could happen with renaming so the
                     # file history gets invalidated). rebuild and try again.
@@ -276,10 +277,9 @@ def debugbuildannotatecache(ui, repo, *p
                     actx.rebuild()
                     try:
                         actx.annotate(rev, rev)
                     except Exception as ex:
                         # possibly a bug, but should not stop us from building
                         # cache for other files.
                         ui.warn(_('fastannotate: %s: failed to '
                                   'build cache: %r\n') % (path, ex))
-        # clear the progress bar
-        ui.write()
+        progress.complete()