Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Unified Diff: sdk/lib/_internal/pub/lib/src/log.dart

Issue 845543003: Mute progress animation while Git is running so it doesn't overwrite credential prompts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/git.dart ('k') | sdk/lib/_internal/pub/lib/src/progress.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
///
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/git.dart ('k') | sdk/lib/_internal/pub/lib/src/progress.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698