Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/log.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/log.dart b/sdk/lib/_internal/pub/lib/src/log.dart |
| index 14627122e29b4eb1d3faec6ed8d03cb045d6124b..1f5956a6c983dc60b9a31b141701a293416a9758 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/log.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/log.dart |
| @@ -42,9 +42,6 @@ const _MAX_TRANSCRIPT = 10000; |
| /// [recordTranscript()] is called. |
| Transcript<Entry> _transcript; |
| -/// All currently-running progress indicators. |
| -final _progresses = new Set<Progress>(); |
| - |
| /// The currently-animated progress indicator, if any. |
| /// |
| /// This will also be in [_progresses]. |
| @@ -374,13 +371,10 @@ void dumpTranscript() { |
| /// information will only be visible at [Level.FINE]. |
| Future progress(String message, Future callback(), {bool fine: false}) { |
| _stopProgress(); |
| + |
| var progress = new Progress(message, fine: fine); |
| _animatedProgress = progress; |
| - _progresses.add(progress); |
| - return callback().whenComplete(() { |
| - progress.stop(); |
| - _progresses.remove(progress); |
| - }); |
| + return callback().whenComplete(progress.stop); |
| } |
| /// Stops animating the running progress indicator, if currently running. |
| @@ -389,6 +383,30 @@ void _stopProgress() { |
| _animatedProgress = null; |
| } |
| +/// The number of outstanding calls to [muteProgress] that have not been unmuted |
| +/// yet. |
| +int _numMutes = 0; |
| + |
| +/// Whether progress animation should be muted or not. |
| +bool get isMuted => _numMutes > 0; |
| + |
| +/// Stops animating any ongoing progress. |
| +/// |
| +/// This is called before spawning Git since Git sometimes writes directly to |
| +/// the terminal to ask for login credentials, which would then get overwritten |
| +/// by the progress animation. |
| +/// |
| +/// Each call to this must be paired with a call to [unmuteProgress]. |
| +void muteProgress() { |
| + _numMutes++; |
| +} |
| + |
| +/// Resumes animating any ongoing progress once all calls to [muteProgress] |
| +/// have made their matching [unmuteProgress]. |
| +void unmuteProgress() { |
| + _numMutes--; |
|
Jacob
2015/01/08 23:46:25
nit:
consider adding
assert(_numMutes > 0);
Bob Nystrom
2015/01/08 23:58:19
Done.
|
| +} |
| + |
| /// Wraps [text] in the ANSI escape codes to make it bold when on a platform |
| /// that supports that. |
| /// |