Mercurial > public > mercurial-scm > hg
comparison hgext/progress.py @ 14837:ec4ba216ddef
progress: make progress bar a singleton to avoid double-progress ui bugs
This helps issue2698 a little, but isn't a complete fix, since
generators still can produce some weird progress bar switching.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 23 Jun 2011 14:55:09 -0500 |
parents | 925cab23d7d5 |
children | 5d261fd00446 |
comparison
equal
deleted
inserted
replaced
14836:925cab23d7d5 | 14837:ec4ba216ddef |
---|---|
249 self.topicstates[topic] = pos, item, unit, total | 249 self.topicstates[topic] = pos, item, unit, total |
250 if now - self.lastprint >= self.refresh and self.topics: | 250 if now - self.lastprint >= self.refresh and self.topics: |
251 self.lastprint = now | 251 self.lastprint = now |
252 self.show(now, topic, *self.topicstates[topic]) | 252 self.show(now, topic, *self.topicstates[topic]) |
253 | 253 |
254 _singleton = None | |
255 | |
254 def uisetup(ui): | 256 def uisetup(ui): |
257 global _singleton | |
255 class progressui(ui.__class__): | 258 class progressui(ui.__class__): |
256 _progbar = None | 259 _progbar = None |
257 | 260 |
258 def progress(self, *args, **opts): | 261 def progress(self, *args, **opts): |
259 self._progbar.progress(*args, **opts) | 262 self._progbar.progress(*args, **opts) |
276 if shouldprint(ui) and not ui.debugflag and not ui.quiet: | 279 if shouldprint(ui) and not ui.debugflag and not ui.quiet: |
277 ui.__class__ = progressui | 280 ui.__class__ = progressui |
278 # we instantiate one globally shared progress bar to avoid | 281 # we instantiate one globally shared progress bar to avoid |
279 # competing progress bars when multiple UI objects get created | 282 # competing progress bars when multiple UI objects get created |
280 if not progressui._progbar: | 283 if not progressui._progbar: |
281 progressui._progbar = progbar(ui) | 284 if _singleton is None: |
285 _singleton = progbar(ui) | |
286 progressui._progbar = _singleton | |
282 | 287 |
283 def reposetup(ui, repo): | 288 def reposetup(ui, repo): |
284 uisetup(repo.ui) | 289 uisetup(repo.ui) |