[PATCH 4 of 5 V2] ui: echo prompt choice only if formatted output is acceptable

Mads Kiilerich mads at kiilerich.com
Fri Oct 10 12:17:41 CDT 2014


On 10/10/2014 05:09 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1412950877 -32400
> #      Fri Oct 10 23:21:17 2014 +0900
> # Node ID 6dcb36c1781c7afbdcee20c793be20e90854e391
> # Parent  80977d0b038a9a42a9b6819e77b80d343c1f711e
> ui: echo prompt choice only if formatted output is acceptable
>
> 9ab18a912c44 is nice for test output, but it also affects command-server
> clients or scripts that have to parse the output.  So enables it only if
> formatted output is acceptable.
>
> This should cover most of command-server clients but chg.
>
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -684,7 +684,8 @@ class ui(object):
>                   r = default
>               # sometimes self.interactive disagrees with isatty,
>               # show response provided on stdin when simulating
> -            if not self._isatty(self.fin):
> +            # but not for commandserver and other scripting
> +            if not self._isatty(self.fin) and self.formatted():

This change is apparently on top of your change from self.isatty to 
self._isatty which isn't on selenic yet? I thought the change to _isatty 
already addressed the command server issue? Why is additional changes on 
top of that needed?

I liked the idea of automagically showing the selected option in the 
right cases. I do not so much like to piggy-back on ui.formatted and 
then explicitly set it all the places where we needed. Then it would be 
better to add a ui.shownonttypromptchoice configuration option ;-)

Other tools scripting Mercurial might want to see the chosen output, 
just like the test suite. I agree that other tools doing the same thing 
(such as command server) don't want it. It would perhaps not be so bad 
to have a separate option for controlling this behaviour ... but I 
really like to have it this way in the test suite.

/Mads


>                   self.write(r, "\n")
>               return r
>           except EOFError:
> diff --git a/tests/test-diff-color.t b/tests/test-diff-color.t
> --- a/tests/test-diff-color.t
> +++ b/tests/test-diff-color.t
> @@ -69,6 +69,7 @@ diffstat
>     $ cat <<EOF >> $HGRCPATH
>     > record =
>     > [ui]
> +  > formatted = true
>     > interactive = true
>     > [diff]
>     > git = True
> diff --git a/tests/test-issue3084.t b/tests/test-issue3084.t
> --- a/tests/test-issue3084.t
> +++ b/tests/test-issue3084.t
> @@ -2,6 +2,8 @@
>     $ cat <<EOF >> $HGRCPATH
>     > [extensions]
>     > largefiles =
> +  > [ui]
> +  > formatted = true
>     > EOF
>   



More information about the Mercurial-devel mailing list