Re: [PATCH python-hglib] Add feature to allow hglib user to get call backs for prompts and output

2016-10-18 Thread Jordi Gutiérrez Hermoso
On Tue, 2016-10-18 at 19:14 -0400, Jordi Gutiérrez Hermoso wrote:
> On Thu, 2016-10-06 at 17:52 +0100, Barry A. Scott wrote:
> > # HG changeset patch
> > # User Barry A. Scott 
> > # Date 1475772736 -3600
> > #  Thu Oct 06 17:52:16 2016 +0100
> > # Branch hglib-gui-features
> > # Node ID 1ac3819a61527836d47f7cd6a113b194c307ffeb
> > # Parent  efc527cc43d7394a5bd0deb1d29c4307592f7528
> > Add feature to allow hglib user to get call backs for prompts and output.
> > 
> > Both pull() and push() have had three new, optiomal, aguments added them.
> 
> Is this really going to be cluttering the output of `hg help
> pull/push`? The longer that gets, the less likely users are to read
> it.

My bad, this is for hglib only. I understand any and all UI options
are welcome there.


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH python-hglib] Add feature to allow hglib user to get call backs for prompts and output

2016-10-18 Thread Jordi Gutiérrez Hermoso
On Thu, 2016-10-06 at 17:52 +0100, Barry A. Scott wrote:
> # HG changeset patch
> # User Barry A. Scott 
> # Date 1475772736 -3600
> #  Thu Oct 06 17:52:16 2016 +0100
> # Branch hglib-gui-features
> # Node ID 1ac3819a61527836d47f7cd6a113b194c307ffeb
> # Parent  efc527cc43d7394a5bd0deb1d29c4307592f7528
> Add feature to allow hglib user to get call backs for prompts and output.
> 
> Both pull() and push() have had three new, optiomal, aguments added them.

Is this really going to be cluttering the output of `hg help
pull/push`? The longer that gets, the less likely users are to read
it.

Indiscriminately growing new options on Mercurial commands, especially
for very niche uses, is very undesirable.


___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH python-hglib] Add feature to allow hglib user to get call backs for prompts and output

2016-10-18 Thread Yuya Nishihara
On Tue, 18 Oct 2016 11:27:00 +0100, Barry Scott wrote:
> > On 16 Oct 2016, at 15:36, Yuya Nishihara  wrote:
> > On Thu, 06 Oct 2016 17:52:38 +0100, Barry A. Scott wrote:
> >> # HG changeset patch
> >> # User Barry A. Scott 
> >> # Date 1475772736 -3600
> >> #  Thu Oct 06 17:52:16 2016 +0100
> >> # Branch hglib-gui-features
> >> # Node ID 1ac3819a61527836d47f7cd6a113b194c307ffeb
> >> # Parent  efc527cc43d7394a5bd0deb1d29c4307592f7528
> >> Add feature to allow hglib user to get call backs for prompts and output.
> > 
> >> The cb prefix was choosen to avoid matching a hg long option name.
> > 
> > That seems fine. merge() already has "cb" argument.
> > 
> >> -def rawcommand(self, args, eh=None, prompt=None, input=None):
> >> +def rawcommand(self, args, eh=None, prompt=None, input=None, 
> >> cbout=None,
> >> +   cberr=None):
> >> """
> >> args is the cmdline (usually built using util.cmdbuilder)
> >> 
> >> @@ -173,9 +174,29 @@
> >> 
> >> input is used to reply to bulk data requests by the server
> >> It receives the max number of bytes to return
> >> +
> >> +cbout is a function that will be called with the stdout data of 
> >> the command
> >> +as it runs.
> >> +
> >> +cberr is a function that will be called with the stderr data of 
> >> the command
> >> +as it runs.
> >> """
> > 
> > Do they need to be separate callbacks? I think prompt() can be extended to
> > take "err" value as an optional third argument.
> 
> There are 2 reasons to have the cbout and cberr call backs. For a push/pull 
> that
> does not prompt it provides the GUI with progress information clearly marked 
> as
> normal, cdout, and error, cberr. The output is also timely, no need to wait 
> for the
> command to complete.

In that case, it'd be nice if we have a generic callback interface like your
another patch. Progress messages aren't limited to push/pull commands.

> When a prompt event happens I found that I cannot rely on figuring out what
> the last prompt was without a timeline of calls to cdout and cderr.

or inspect the last lines of both out/err channels? Anyway it's unreliable to
read the prompt line, so we'll need a better channel protocol in future.

> For example cdout gets the “user:” prompt but cderr gets the “password:”.
> (Why is “password:” sent to stderr? Bug? Feature?)

That is considered a feature of hg, but isn't nice in command-server session.
I made an extension to send more information over the pipe. It's just a hack.
My current plan is to add an option to send prompt, progress, and status
messages to a separate (e.g. 'C'-ontrol) channel.

https://bitbucket.org/tortoisehg/thg/src/3.9.2/tortoisehg/util/pipeui.py
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH python-hglib] Add feature to allow hglib user to get call backs for prompts and output

2016-10-18 Thread Barry Scott

> On 16 Oct 2016, at 15:36, Yuya Nishihara  wrote:
> 
> On Thu, 06 Oct 2016 17:52:38 +0100, Barry A. Scott wrote:
>> # HG changeset patch
>> # User Barry A. Scott 
>> # Date 1475772736 -3600
>> #  Thu Oct 06 17:52:16 2016 +0100
>> # Branch hglib-gui-features
>> # Node ID 1ac3819a61527836d47f7cd6a113b194c307ffeb
>> # Parent  efc527cc43d7394a5bd0deb1d29c4307592f7528
>> Add feature to allow hglib user to get call backs for prompts and output.
> 
>> The cb prefix was choosen to avoid matching a hg long option name.
> 
> That seems fine. merge() already has "cb" argument.
> 
>> -def rawcommand(self, args, eh=None, prompt=None, input=None):
>> +def rawcommand(self, args, eh=None, prompt=None, input=None, cbout=None,
>> +   cberr=None):
>> """
>> args is the cmdline (usually built using util.cmdbuilder)
>> 
>> @@ -173,9 +174,29 @@
>> 
>> input is used to reply to bulk data requests by the server
>> It receives the max number of bytes to return
>> +
>> +cbout is a function that will be called with the stdout data of the 
>> command
>> +as it runs.
>> +
>> +cberr is a function that will be called with the stderr data of the 
>> command
>> +as it runs.
>> """
> 
> Do they need to be separate callbacks? I think prompt() can be extended to
> take "err" value as an optional third argument.
> 


There are 2 reasons to have the cbout and cberr call backs. For a push/pull that
does not prompt it provides the GUI with progress information clearly marked as
normal, cdout, and error, cberr. The output is also timely, no need to wait for 
the
command to complete.

When a prompt event happens I found that I cannot rely on figuring out what
the last prompt was without a timeline of calls to cdout and cderr.

For example cdout gets the “user:” prompt but cderr gets the “password:”.
(Why is “password:” sent to stderr? Bug? Feature?)

My code can see that the last message was “password:” on cberr and know
that a password response is required.

I did not change the interface to prompt as it is already used elsewhere and
with the addition of cdout and cderr I can ignore its parameters.

Adding err to the prompt call may, or may not, be useful in other use cases.

Barry

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH python-hglib] Add feature to allow hglib user to get call backs for prompts and output

2016-10-07 Thread Barry Scott
On Thursday, 6 October 2016 15:03:32 BST timeless wrote:
> On Thu, Oct 6, 2016 at 12:52 PM, Barry A. Scott  
wrote:
> > Both pull() and push() have had three new, optiomal, aguments added them.
> 
> optional ; arguments

I'll fix the commit message once I have any more feedback.

Barry

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel