Submitter | Yuya Nishihara |
---|---|
Date | Oct. 8, 2014, 2:48 p.m. |
Message ID | <49193989bbd88445b156.1412779733@mimosa> |
Download | mbox | patch |
Permalink | /patch/6154/ |
State | Accepted |
Commit | 524b786bd54f8658965cbcf9a08458aa493e8c1f |
Headers | show |
Comments
On Wed, Oct 08, 2014 at 11:48:53PM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1412769061 -32400 > # Wed Oct 08 20:51:01 2014 +0900 > # Node ID 49193989bbd88445b156f0c6891610f34a56447f > # Parent a1eb21f5caea4366310e32aa85248791d5bbfa0c > ui: disable echo back of prompt input if ui is set to non-tty purposely > > 9ab18a912c44 is nice for test output, but it also affects command-server > channel. Command-server client shouldn't receive echo-back message, which > makes it harder to parse the output. > > diff --git a/mercurial/ui.py b/mercurial/ui.py > --- a/mercurial/ui.py > +++ b/mercurial/ui.py > @@ -684,7 +684,9 @@ class ui(object): > r = default > # sometimes self.interactive disagrees with isatty, > # show response provided on stdin when simulating > - if not util.isatty(self.fin): > + # but commandserver Should there be more of a thought here? Or is "but" a typo? > + if (not util.isatty(self.fin) > + and not self.configbool('ui', 'nontty')): > self.write(r, "\n") > return r > except EOFError: > diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t > --- a/tests/test-commandserver.t > +++ b/tests/test-commandserver.t > @@ -497,6 +497,9 @@ check that local configs for the cached > > @command("debuggetpass", norepo=True) > > def debuggetpass(ui): > > ui.write("%s\\n" % ui.getpass()) > + > @command("debugprompt", norepo=True) > + > def debugprompt(ui): > + > ui.write("%s\\n" % ui.prompt("prompt:")) > > EOF > $ cat <<EOF >> .hg/hgrc > > [extensions] > @@ -511,8 +514,13 @@ check that local configs for the cached > ... runcommand(server, ['debuggetpass', '--config', > ... 'ui.interactive=True'], > ... input=cStringIO.StringIO('1234\n')) > + ... runcommand(server, ['debugprompt', '--config', > + ... 'ui.interactive=True'], > + ... input=cStringIO.StringIO('5678\n')) > *** runcommand debuggetpass --config ui.interactive=True > password: 1234 > + *** runcommand debugprompt --config ui.interactive=True > + prompt: 5678 > > > start without repository: > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
On Thu, 9 Oct 2014 10:05:20 -0400, Augie Fackler wrote: > On Wed, Oct 08, 2014 at 11:48:53PM +0900, Yuya Nishihara wrote: > > # HG changeset patch > > # User Yuya Nishihara <yuya@tcha.org> > > # Date 1412769061 -32400 > > # Wed Oct 08 20:51:01 2014 +0900 > > # Node ID 49193989bbd88445b156f0c6891610f34a56447f > > # Parent a1eb21f5caea4366310e32aa85248791d5bbfa0c > > ui: disable echo back of prompt input if ui is set to non-tty purposely > > > > 9ab18a912c44 is nice for test output, but it also affects command-server > > channel. Command-server client shouldn't receive echo-back message, which > > makes it harder to parse the output. > > > > diff --git a/mercurial/ui.py b/mercurial/ui.py > > --- a/mercurial/ui.py > > +++ b/mercurial/ui.py > > @@ -684,7 +684,9 @@ class ui(object): > > r = default > > # sometimes self.interactive disagrees with isatty, > > # show response provided on stdin when simulating > > - if not util.isatty(self.fin): > > + # but commandserver > > Should there be more of a thought here? Or is "but" a typo? It seemed noisy to write long comment about commandserver here. Instead, I'm thinking of new internal flag to control the echo, and set this flag off by commandserver. if self.configbool('ui', 'promptecho', not util.isatty(self.fin)): self.write(r, "\n") > > + if (not util.isatty(self.fin) > > + and not self.configbool('ui', 'nontty')): > > self.write(r, "\n") > > return r > > except EOFError: Regards,
On 10/09/2014 04:30 PM, Yuya Nishihara wrote: > On Thu, 9 Oct 2014 10:05:20 -0400, Augie Fackler wrote: >> On Wed, Oct 08, 2014 at 11:48:53PM +0900, Yuya Nishihara wrote: >>> # HG changeset patch >>> # User Yuya Nishihara <yuya@tcha.org> >>> # Date 1412769061 -32400 >>> # Wed Oct 08 20:51:01 2014 +0900 >>> # Node ID 49193989bbd88445b156f0c6891610f34a56447f >>> # Parent a1eb21f5caea4366310e32aa85248791d5bbfa0c >>> ui: disable echo back of prompt input if ui is set to non-tty purposely >>> >>> 9ab18a912c44 is nice for test output, but it also affects command-server >>> channel. Command-server client shouldn't receive echo-back message, which >>> makes it harder to parse the output. >>> >>> diff --git a/mercurial/ui.py b/mercurial/ui.py >>> --- a/mercurial/ui.py >>> +++ b/mercurial/ui.py >>> @@ -684,7 +684,9 @@ class ui(object): >>> r = default >>> # sometimes self.interactive disagrees with isatty, >>> # show response provided on stdin when simulating >>> - if not util.isatty(self.fin): >>> + # but commandserver >> Should there be more of a thought here? Or is "but" a typo? > It seemed noisy to write long comment about commandserver here. It could perhaps be more of a full sentence: # sometimes self.interactive disagrees with isatty, # show response provided on stdin when simulating # but not for commandserver and other scripting > Instead, I'm thinking of new internal flag to control the echo, and set > this flag off by commandserver. > > if self.configbool('ui', 'promptecho', not util.isatty(self.fin)): > self.write(r, "\n") I assume command server uses plain? How about if not util.isatty(self.fin) and not self.plain(): /Mads
On Thu, 09 Oct 2014 16:50:27 +0200, Mads Kiilerich wrote: > On 10/09/2014 04:30 PM, Yuya Nishihara wrote: > > On Thu, 9 Oct 2014 10:05:20 -0400, Augie Fackler wrote: > >> On Wed, Oct 08, 2014 at 11:48:53PM +0900, Yuya Nishihara wrote: > >>> # HG changeset patch > >>> # User Yuya Nishihara <yuya@tcha.org> > >>> # Date 1412769061 -32400 > >>> # Wed Oct 08 20:51:01 2014 +0900 > >>> # Node ID 49193989bbd88445b156f0c6891610f34a56447f > >>> # Parent a1eb21f5caea4366310e32aa85248791d5bbfa0c > >>> ui: disable echo back of prompt input if ui is set to non-tty purposely > >>> > >>> 9ab18a912c44 is nice for test output, but it also affects command-server > >>> channel. Command-server client shouldn't receive echo-back message, which > >>> makes it harder to parse the output. > >>> > >>> diff --git a/mercurial/ui.py b/mercurial/ui.py > >>> --- a/mercurial/ui.py > >>> +++ b/mercurial/ui.py > >>> @@ -684,7 +684,9 @@ class ui(object): > >>> r = default > >>> # sometimes self.interactive disagrees with isatty, > >>> # show response provided on stdin when simulating > >>> - if not util.isatty(self.fin): > >>> + # but commandserver > >> Should there be more of a thought here? Or is "but" a typo? > > It seemed noisy to write long comment about commandserver here. > > It could perhaps be more of a full sentence: > > # sometimes self.interactive disagrees with isatty, > # show response provided on stdin when simulating > # but not for commandserver and other scripting Sounds nice, thanks. > > Instead, I'm thinking of new internal flag to control the echo, and set > > this flag off by commandserver. > > > > if self.configbool('ui', 'promptecho', not util.isatty(self.fin)): > > self.write(r, "\n") > > I assume command server uses plain? How about > > if not util.isatty(self.fin) and not self.plain(): It depends. Libraries that have to parse the output will set HGPLAIN, but there's a weird client that tries to mimic all behaviors of hg command. Regards,
Patch
diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -684,7 +684,9 @@ class ui(object): r = default # sometimes self.interactive disagrees with isatty, # show response provided on stdin when simulating - if not util.isatty(self.fin): + # but commandserver + if (not util.isatty(self.fin) + and not self.configbool('ui', 'nontty')): self.write(r, "\n") return r except EOFError: diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t --- a/tests/test-commandserver.t +++ b/tests/test-commandserver.t @@ -497,6 +497,9 @@ check that local configs for the cached > @command("debuggetpass", norepo=True) > def debuggetpass(ui): > ui.write("%s\\n" % ui.getpass()) + > @command("debugprompt", norepo=True) + > def debugprompt(ui): + > ui.write("%s\\n" % ui.prompt("prompt:")) > EOF $ cat <<EOF >> .hg/hgrc > [extensions] @@ -511,8 +514,13 @@ check that local configs for the cached ... runcommand(server, ['debuggetpass', '--config', ... 'ui.interactive=True'], ... input=cStringIO.StringIO('1234\n')) + ... runcommand(server, ['debugprompt', '--config', + ... 'ui.interactive=True'], + ... input=cStringIO.StringIO('5678\n')) *** runcommand debuggetpass --config ui.interactive=True password: 1234 + *** runcommand debugprompt --config ui.interactive=True + prompt: 5678 start without repository: