mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
progress: clear progress bar when locking to suspend
Summary: The recent changes to the progress engine to work around locking bugs removed the `clear` step of `progress.suspend`. This leads to garbled output when a progress bar is ongoing. Restore it by adding a new lock method to the engine. Also add a `--with-output` option to `hg debugprogress` to test this. Reviewed By: mitrandir77 Differential Revision: D12838415 fbshipit-source-id: 83ed516b528d0b0bbe37945141d50b50da00ac8e
This commit is contained in:
parent
2deae85b42
commit
92674884fd
@ -3053,11 +3053,14 @@ def debugdrawdag(ui, repo, **opts):
|
||||
("s", "spinner", False, _("use a progress spinner")),
|
||||
("n", "nototal", False, _("don't include the total")),
|
||||
("b", "bytes", False, _("use a bytes format function")),
|
||||
("", "with-output", False, _("also print output every 10%")),
|
||||
],
|
||||
_("NUMBER"),
|
||||
norepo=True,
|
||||
)
|
||||
def debugprogress(ui, number, spinner=False, nototal=False, bytes=False):
|
||||
def debugprogress(
|
||||
ui, number, spinner=False, nototal=False, bytes=False, with_output=False
|
||||
):
|
||||
"""
|
||||
Initiate a progress bar and increment the progress NUMBER times.
|
||||
|
||||
@ -3069,18 +3072,30 @@ def debugprogress(ui, number, spinner=False, nototal=False, bytes=False):
|
||||
|
||||
formatfunc = util.bytecount if bytes else None
|
||||
|
||||
if with_output:
|
||||
outputfreq = num // 10
|
||||
if outputfreq == 0:
|
||||
outputfreq = 1
|
||||
else:
|
||||
outputfreq = None
|
||||
|
||||
if spinner:
|
||||
with progress.spinner(ui, _spinning):
|
||||
for i in xrange(num):
|
||||
pass
|
||||
if outputfreq and i % outputfreq == 0:
|
||||
ui.write(("processed %d items") % i)
|
||||
elif nototal:
|
||||
with progress.bar(ui, _spinning, formatfunc=formatfunc) as p:
|
||||
for i in xrange(num):
|
||||
p.value = (i, "item %s" % i)
|
||||
if outputfreq and i % outputfreq == 0:
|
||||
ui.write(("processed %d items") % i)
|
||||
else:
|
||||
with progress.bar(ui, _spinning, total=num, formatfunc=formatfunc) as p:
|
||||
for i in xrange(num):
|
||||
p.value = (i, "item %s" % i)
|
||||
if outputfreq and i % outputfreq == 0:
|
||||
ui.write(("processed %d items\n") % i)
|
||||
|
||||
|
||||
def _findtreemanifest(ctx):
|
||||
|
@ -432,6 +432,14 @@ class engine(object):
|
||||
with b, b, b, b, b, b:
|
||||
yield
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _lockclear(self):
|
||||
with self.lock():
|
||||
bar = self._currentbar()
|
||||
if bar is not None:
|
||||
bar._enginerenderer.clear()
|
||||
yield
|
||||
|
||||
def resetstate(self):
|
||||
with self.lock():
|
||||
self._clear()
|
||||
@ -449,7 +457,7 @@ class engine(object):
|
||||
self._bars.append(bar)
|
||||
self._recalculatedisplay(now)
|
||||
global suspend
|
||||
suspend = self.lock
|
||||
suspend = self._lockclear
|
||||
self._cond.notify_all()
|
||||
|
||||
def unregister(self, bar):
|
||||
|
@ -306,7 +306,7 @@ Show all commands + options
|
||||
debugpathcomplete: full, normal, added, removed
|
||||
debugpickmergetool: rev, changedelete, include, exclude, tool
|
||||
debugprocesstree:
|
||||
debugprogress: spinner, nototal, bytes
|
||||
debugprogress: spinner, nototal, bytes, with-output
|
||||
debugpushkey:
|
||||
debugpvec:
|
||||
debugrebuilddirstate: rev, minimal
|
||||
|
Loading…
Reference in New Issue
Block a user