darcs

Patch 561 darcs now uses tty instead of stdin in promptChar

Title darcs now uses tty instead of stdin in promptChar
Superseder resolve issue1648: darcs now uses tty instead of stdin in darcs apply --interactive
View: 567
Nosy List bsrkaditya, ganesh
Related Issues
Status obsoleted Assigned To ganesh
Milestone

Created on 2011-02-23.06:40:26 by bsrkaditya, last changed 2011-04-01.13:20:25 by ganesh.

Files
File name Status Uploaded Type Edit Remove
resolve-issue1648_-darcs-now-uses-tty-instead-of-stdin-in-interactive-modes.dpatch bsrkaditya, 2011-02-23.06:40:25 application/x-darcs-patch
resolve-issue1648_-darcs-now-uses-tty-instead-of-stdin-in-interactive-modes.dpatch bsrkaditya, 2011-02-23.06:58:26 application/x-darcs-patch
unnamed bsrkaditya, 2011-02-23.06:40:25 text/x-darcs-patch
unnamed bsrkaditya, 2011-02-23.06:40:25
unnamed bsrkaditya, 2011-02-23.06:58:26 text/x-darcs-patch
unnamed bsrkaditya, 2011-02-23.06:58:26
unnamed bsrkaditya, 2011-02-24.10:17:38 text/html
See mailing list archives for discussion on individual patches.
Messages
msg13743 (view) Author: bsrkaditya Date: 2011-02-23.06:40:25
1 patch for repository http://darcs.net/screened:

Wed Feb 23 11:40:17 IST 2011  bsrkaditya@gmail.com
  * resolve issue1648: darcs now uses tty instead of stdin in promptChar

I have modified promptChar, to use terminal instead of stdin.
I grepped through the source files for promptChar, and always,
promptChar is used for interactive input (mostly yn questions).

BTW, is interactive mode input limited to only menu choices?

If so, then the issue is resolved.
Attachments
msg13744 (view) Author: bsrkaditya Date: 2011-02-23.06:58:26
1 patch for repository http://darcs.net/screened:

Wed Feb 23 12:13:22 IST 2011  bsrkaditya@gmail.com
  * resolve issue1648: darcs now uses tty instead of stdin in interactive modes

preferTerm has not been imported in the previous patch
use this one instead
Attachments
msg13748 (view) Author: bsrkaditya Date: 2011-02-24.07:52:59
I have ran the tests using 'cabal test',
and apparently my change completely messes up
the system used for writing tests.

The tests use echo and then pipes to give input to
interactive statements. For example,
echo y | darcs amend -a foo

So, if this patch needs to be accepted, we need a
complete rewrite of the tests.

Or maybe it is better if we can somehow signal to darcs
on weather to use tty or stdin?

Regular users use tty, but in scripts we can use stdin.
msg13749 (view) Author: ganesh Date: 2011-02-24.08:42:35
I can't see how the tests could sensibly be rewritten. So we'd need a flag  
to control this behaviour.

Are there any use cases for it other than darcs apply --interactive?
msg13750 (view) Author: bsrkaditya Date: 2011-02-24.10:17:38
On Thu, Feb 24, 2011 at 2:12 PM, Ganesh Sittampalam <bugs@darcs.net> wrote:

>
> Ganesh Sittampalam <ganesh@earth.li> added the comment:
>
> Are there any use cases for it other than darcs apply --interactive?
>
>
Yes, promptChar is used to take input in questions
where user is supposed to give input as a single char.

 So this change effects it to all commands which prompt
the user, like darcs record, which asks the user:
 Shall I record this change? (1/1)  [ynW...], or ? for more options:

> __________________________________
> Darcs bug tracker <bugs@darcs.net>
> <http://bugs.darcs.net/patch561>
> __________________________________
>



-- 
BSRK Aditya
Attachments
msg13751 (view) Author: ganesh Date: 2011-02-24.10:35:04
Is that behaviour useful in any case other than apply --interactive? The 
use case in issue1648 is piping a bunch of patches in a patch file into 
darcs apply and wanting to be able to select from those  patches 
interactively. What other scenarios are there where darcs needs those 
two input streams, one of data from stdin and another of user 
interaction from tty?
msg13752 (view) Author: kowey Date: 2011-02-24.11:33:01
On Thu, Feb 24, 2011 at 08:42:36 +0000, Ganesh Sittampalam wrote:
> I can't see how the tests could sensibly be rewritten. So we'd need a flag  
> to control this behaviour.

Is it technically feasible to have some kind of command, let's call it
fake-terminal, that runs a command, accepts input on stdin and pretends
to that command that the input was typed in?

  echo yn | fake-terminal darcs ...

Is something like Expect what I'm thinking of?
  http://en.wikipedia.org/wiki/Expect

Could we "just use expect"? (That sounds like it'd involve a lot of
exit 200) or cook up a really brain-dead version?

(Perhaps I misunderstand the issue)

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
For a faster response, try +44 (0)1273 64 2905 or
xmpp:kowey@jabber.fr (Jabber or Google Talk only)
msg13757 (view) Author: ganesh Date: 2011-02-24.23:06:55
On 24/02/2011 11:22, Eric Kow wrote:
> On Thu, Feb 24, 2011 at 08:42:36 +0000, Ganesh Sittampalam wrote:
>> I can't see how the tests could sensibly be rewritten. So we'd need a flag
>> to control this behaviour.
>
> Is it technically feasible to have some kind of command, let's call it
> fake-terminal, that runs a command, accepts input on stdin and pretends
> to that command that the input was typed in?
>
>    echo yn | fake-terminal darcs ...
>
> Is something like Expect what I'm thinking of?
>    http://en.wikipedia.org/wiki/Expect
>
> Could we "just use expect"? (That sounds like it'd involve a lot of
> exit 200) or cook up a really brain-dead version?
>
> (Perhaps I misunderstand the issue)


Ah, good point. We probably could do something like that.

But we'd also be breaking anyone trying to use the darcs binary 
programmatically in some way. If the only benefit is for apply 
--interactive, I think we shouldn't do that; providing a flag should 
work fine for that scenario.

Ganesh
History
Date User Action Args
2011-02-23 06:40:26bsrkadityacreate
2011-02-23 06:58:26bsrkadityasetfiles: + unnamed, resolve-issue1648_-darcs-now-uses-tty-instead-of-stdin-in-interactive-modes.dpatch, unnamed
messages: + msg13744
title: resolve issue1648: darcs now uses tty instead of stdin... -> darcs now uses tty instead of stdin in promptChar
2011-02-24 07:52:59bsrkadityasetmessages: + msg13748
2011-02-24 08:42:35ganeshsetmessages: + msg13749
2011-02-24 10:17:38bsrkadityasetfiles: + unnamed
messages: + msg13750
2011-02-24 10:35:05ganeshsetmessages: + msg13751
2011-02-24 11:33:01koweysetmessages: + msg13752
2011-02-24 23:06:56ganeshsetmessages: + msg13757
2011-04-01 11:09:28ganeshsetassignedto: ganesh
nosy: + ganesh
2011-04-01 13:20:25ganeshsetstatus: needs-review -> obsoleted
superseder: + resolve issue1648: darcs now uses tty instead of stdin in darcs apply --interactive