##// END OF EJS Templates
progress: move the singleton logic to the ui module...
progress: move the singleton logic to the ui module The use of a singleton for all of progress handling is debatable (because config may vary). However this is how the extension has been doing it so far. We move that code into the ui module because this is where is should belong when progress is moved into core.

File last commit:

r25498:7a5335ed default
r25498:7a5335ed default
Show More
progress.py
77 lines | 3.0 KiB | text/x-python | PythonLexer
Augie Fackler
Progress bar extension
r10434 # progress.py show progress bars for some actions
#
# Copyright (C) 2010 Augie Fackler <durin42@gmail.com>
#
Augie Fackler
progress: Use the same GPL boilerplate as most hg files
r15772 # This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
Augie Fackler
Progress bar extension
r10434
"""show progress bars for some actions
timeless
progress: fix description
r10450 This extension uses the progress information logged by hg commands
to draw progress bars that are as informative as possible. Some progress
Augie Fackler
Progress bar extension
r10434 bars only offer indeterminate information, while others have a definite
end point.
The following settings are available::
[progress]
delay = 3 # number of seconds (float) before showing the progress bar
Augie Fackler
progress: add a changedelay to prevent parallel topics from flapping (issue2698)...
r14838 changedelay = 1 # changedelay: minimum delay before showing a new topic.
# If set to less than 3 * refresh, that value will
# be used instead.
Augie Fackler
Progress bar extension
r10434 refresh = 0.1 # time in seconds between refreshes of the progress bar
Augie Fackler
progress: include time estimate as part of the default progress format
r13148 format = topic bar number estimate # format of the progress bar
Augie Fackler
Progress bar extension
r10434 width = <none> # if set, the maximum width of the progress information
# (that is, min(width, term width) will be used)
clear-complete = True # clear the progress bar after it's done
Augie Fackler
progress: document progress.disable config option
r10656 disable = False # if true, don't show a progress bar
Augie Fackler
progress: use stderr instead of stdout; check stderr.isatty()...
r10788 assume-tty = False # if true, ALWAYS show a progress bar, unless
# disable is given
Augie Fackler
Progress bar extension
r10434
Augie Fackler
progress: only show time estimate when progress format contains 'estimate'
r13147 Valid entries for the format field are topic, bar, number, unit,
Martin Geisler
progress: add speed format...
r14280 estimate, speed, and item. item defaults to the last 20 characters of
the item, but this can be changed by adding either ``-<num>`` which
would take the last num characters, or ``+<num>`` for the first num
Augie Fackler
progress: only show time estimate when progress format contains 'estimate'
r13147 characters.
Augie Fackler
Progress bar extension
r10434 """
Pierre-Yves David
progress: move most extension code into a 'mercurial.progress' module...
r25497 from mercurial import progress
Pierre-Yves David
progress: move the singleton logic to the ui module...
r25498 from mercurial import ui as uimod
Augie Fackler
progress: make progress bar a singleton to avoid double-progress ui bugs...
r14837
Augie Fackler
Progress bar extension
r10434 def uisetup(ui):
Brodie Rao
color/progress: subclass ui instead of using wrapfunction (issue2096)...
r11555 class progressui(ui.__class__):
_progbar = None
David Soria Parra
progress: check for ui.quiet and ui.debugflag before we write...
r15662 def _quiet(self):
return self.debugflag or self.quiet
Brodie Rao
color/progress: subclass ui instead of using wrapfunction (issue2096)...
r11555 def progress(self, *args, **opts):
David Soria Parra
progress: check for ui.quiet and ui.debugflag before we write...
r15662 if not self._quiet():
self._progbar.progress(*args, **opts)
Brodie Rao
color/progress: subclass ui instead of using wrapfunction (issue2096)...
r11555 return super(progressui, self).progress(*args, **opts)
def write(self, *args, **opts):
David Soria Parra
progress: check for ui.quiet and ui.debugflag before we write...
r15662 if not self._quiet() and self._progbar.printed:
Brodie Rao
color/progress: subclass ui instead of using wrapfunction (issue2096)...
r11555 self._progbar.clear()
return super(progressui, self).write(*args, **opts)
def write_err(self, *args, **opts):
David Soria Parra
progress: check for ui.quiet and ui.debugflag before we write...
r15662 if not self._quiet() and self._progbar.printed:
Brodie Rao
color/progress: subclass ui instead of using wrapfunction (issue2096)...
r11555 self._progbar.clear()
return super(progressui, self).write_err(*args, **opts)
Steve Borho
progress: provide an explicit disable method for developers...
r10540 # Apps that derive a class from ui.ui() can use
# setconfig('progress', 'disable', 'True') to disable this extension
if ui.configbool('progress', 'disable'):
return
Pierre-Yves David
progress: move most extension code into a 'mercurial.progress' module...
r25497 if progress.shouldprint(ui) and not ui.debugflag and not ui.quiet:
Pierre-Yves David
progress: stop double-wrapping of ui class...
r25482 dval = object()
if getattr(ui, '_progbar', dval) is dval:
ui.__class__ = progressui
# we instantiate one globally-shared progress bar to avoid
# competing progress bars when multiple UI objects get created
if not progressui._progbar:
Pierre-Yves David
progress: move the singleton logic to the ui module...
r25498 progressui._progbar = uimod.getprogbar(ui)
Augie Fackler
Progress bar extension
r10434
def reposetup(ui, repo):
uisetup(repo.ui)