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

Unified Diff: sdk/lib/_internal/pub_generated/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
Index: sdk/lib/_internal/pub_generated/lib/src/log.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/log.dart b/sdk/lib/_internal/pub_generated/lib/src/log.dart
index 2b8cb4aed223209427e15fee9fc60398d3d4eae7..d1a437c644445e487349566e7bc288a0e1226d96 100644
--- a/sdk/lib/_internal/pub_generated/lib/src/log.dart
+++ b/sdk/lib/_internal/pub_generated/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].
@@ -376,13 +373,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.
@@ -391,6 +385,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--;
+}
+
/// Wraps [text] in the ANSI escape codes to make it bold when on a platform
/// that supports that.
///

Powered by Google App Engine
This is Rietveld 408576698