Mercurial > public > mercurial-scm > hg-stable
diff mercurial/ui.py @ 25498:7a5335ed7e1a
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 07 Jun 2015 17:26:34 -0700 |
parents | 3ff4b07412ad |
children | 0fa964d6fd48 |
line wrap: on
line diff
--- a/mercurial/ui.py Sun Jun 07 17:19:20 2015 -0700 +++ b/mercurial/ui.py Sun Jun 07 17:26:34 2015 -0700 @@ -7,7 +7,7 @@ from i18n import _ import errno, getpass, os, socket, sys, tempfile, traceback -import config, scmutil, util, error, formatter +import config, scmutil, util, error, formatter, progress from node import hex samplehgrcs = { @@ -983,3 +983,15 @@ self.name = name # We'll do more intelligent things with rawloc in the future. self.loc = rawloc + +# we instantiate one globally shared progress bar to avoid +# competing progress bars when multiple UI objects get created +_progresssingleton = None + +def getprogbar(ui): + global _progresssingleton + if _progresssingleton is None: + # passing 'ui' object to the singleton is fishy, + # this is how the extension used to work but feel free to rework it. + _progresssingleton = progress.progbar(ui) + return _progresssingleton