Patchwork progress: display progress bar when HGPLAINEXCEPT contains "progress"

login
register
mail settings
Submitter Matt Anderson
Date Feb. 17, 2016, 11:23 p.m.
Message ID <2c42cd3739baaef3f756.1455751434@andersonmat-mbp>
Download mbox | patch
Permalink /patch/13258/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Matt Anderson - Feb. 17, 2016, 11:23 p.m.
# HG changeset patch
# User Matt Anderson <andersonmat@fb.com>
# Date 1455751110 28800
#      Wed Feb 17 15:18:30 2016 -0800
# Node ID 2c42cd3739baaef3f756b3366c2885efa5b40575
# Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
progress: display progress bar when HGPLAINEXCEPT contains "progress"

This patch changes "progress.shouldprint()" so a feature name is provided to
"ui.plain()" to determine if there is an exception specificed in HGPLAINEXCEPT
for the progress extension.

This will allow user-facing scripts to provide progress output while HGPLAIN
is enabled.
Yuya Nishihara - Feb. 20, 2016, 8:41 a.m.
On Wed, 17 Feb 2016 15:23:54 -0800, Matt Anderson wrote:
> # HG changeset patch
> # User Matt Anderson <andersonmat@fb.com>
> # Date 1455751110 28800
> #      Wed Feb 17 15:18:30 2016 -0800
> # Node ID 2c42cd3739baaef3f756b3366c2885efa5b40575
> # Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
> progress: display progress bar when HGPLAINEXCEPT contains "progress"

Looks good. Pushed to the clowncopter, thanks.

> --- a/tests/test-progress.t
> +++ b/tests/test-progress.t
> @@ -79,6 +79,13 @@
>  no progress with --quiet
>    $ hg -y loop 3 --quiet
>  
> +test plain mode exception
> +  $ export HGPLAINEXCEPT=progress
> +  $ hg -y loop 1

Dropped the bashism.

Patch

diff --git a/mercurial/help/environment.txt b/mercurial/help/environment.txt
--- a/mercurial/help/environment.txt
+++ b/mercurial/help/environment.txt
@@ -69,6 +69,8 @@ 
         Preserve internationalization.
     ``revsetalias``
         Don't remove revset aliases.
+    ``progress``
+        Don't hide progress output.
 
     Setting HGPLAINEXCEPT to anything (even an empty string) will
     enable plain mode.
diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -18,7 +18,7 @@ 
     return ' '.join(s for s in args if s)
 
 def shouldprint(ui):
-    return not (ui.quiet or ui.plain()) and (
+    return not (ui.quiet or ui.plain('progress')) and (
         ui._isatty(sys.stderr) or ui.configbool('progress', 'assume-tty'))
 
 def fmtremaining(seconds):
diff --git a/tests/test-progress.t b/tests/test-progress.t
--- a/tests/test-progress.t
+++ b/tests/test-progress.t
@@ -79,6 +79,13 @@ 
 no progress with --quiet
   $ hg -y loop 3 --quiet
 
+test plain mode exception
+  $ export HGPLAINEXCEPT=progress
+  $ hg -y loop 1
+  \r (no-eol) (esc)
+  loop [                                                ] 0/1\r (no-eol) (esc)
+                                                              \r (no-eol) (esc)
+
 test nested short-lived topics (which shouldn't display with nestdelay):
 
   $ hg -y loop 3 --nested