comparison 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
comparison
equal deleted inserted replaced
25497:93b8b0049932 25498:7a5335ed7e1a
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from i18n import _ 8 from i18n import _
9 import errno, getpass, os, socket, sys, tempfile, traceback 9 import errno, getpass, os, socket, sys, tempfile, traceback
10 import config, scmutil, util, error, formatter 10 import config, scmutil, util, error, formatter, progress
11 from node import hex 11 from node import hex
12 12
13 samplehgrcs = { 13 samplehgrcs = {
14 'user': 14 'user':
15 """# example user config (see "hg help config" for more info) 15 """# example user config (see "hg help config" for more info)
981 ``rawloc`` is the raw location, as defined in the config. 981 ``rawloc`` is the raw location, as defined in the config.
982 """ 982 """
983 self.name = name 983 self.name = name
984 # We'll do more intelligent things with rawloc in the future. 984 # We'll do more intelligent things with rawloc in the future.
985 self.loc = rawloc 985 self.loc = rawloc
986
987 # we instantiate one globally shared progress bar to avoid
988 # competing progress bars when multiple UI objects get created
989 _progresssingleton = None
990
991 def getprogbar(ui):
992 global _progresssingleton
993 if _progresssingleton is None:
994 # passing 'ui' object to the singleton is fishy,
995 # this is how the extension used to work but feel free to rework it.
996 _progresssingleton = progress.progbar(ui)
997 return _progresssingleton