Command server

Idan Kamara idankk86 at gmail.com
Sun Dec 18 07:09:09 CST 2011


On Sun, Dec 18, 2011 at 1:50 PM, Sergey Antonov <sergant_ at mail.ru> wrote:

> On 18.12.2011 14:27, Idan Kamara wrote:
>
>> On Sun, Dec 18, 2011 at 8:38 AM, Sergey Antonov <sergant_ at mail.ru
>> <mailto:sergant_ at mail.ru>> wrote:
>>
>>    On 18.12.2011 1:45, Idan Kamara wrote:
>>
>>            I've made some tests and found that commands like
>>            incoming/outgoing/push/pull does not asks for credentials via
>>            command server protocol and simply aborts with 'abort: http
>>            authorization required'.
>>
>>
>>        Please provide an example (preferably with python-hglib). I
>>        don't recall
>>        trying it but I don't see why it shouldn't work.
>>
>>
>>    Here are steps to reproduce:
>>    1. hg clone https://bitbucket.org/__**zzsergant/testcmdsrv<https://bitbucket.org/__zzsergant/testcmdsrv>
>>
>>    <https://bitbucket.org/**zzsergant/testcmdsrv<https://bitbucket.org/zzsergant/testcmdsrv>
>> >
>>    2. cd testcmdsrv
>>    3. echo 2 >> a.txt
>>    4. hg ci -m "edit"
>>    5. Create cmdsrv.py and copy example client from part 5 at
>>    http://mercurial.selenic.com/_**_wiki/CommandServer<http://mercurial.selenic.com/__wiki/CommandServer>
>>
>>    <http://mercurial.selenic.com/**wiki/CommandServer<http://mercurial.selenic.com/wiki/CommandServer>
>> >
>>    6. cmdsrv.py push
>>
>>
>> I updated the example client, try `cmdsrv.py --config ui.interaction=1
>> push`
>>
>>
> Thanks, now it works. This switch was not mentioned on the command server
> page, that is why I missed it.
>
> But I have another problem.
> If I run this script from console (cmd.exe) it works fine (asked for
> username/password).
> But, if I run it from IDE (which redirects output to a tool window), then
> it hang after I enter username.
>
> Looks like it asks for password in a different way, than for username.
> Because username is echoed in the console, but password is not.
> I don't understand how it asks for password.
>
> Do you have any hints ?
>

Like Yuya said, it does ask for a password in a different way (uses
getpass.getpass),
so it doesn't echo to the console.

Looks like the Windows implementation checks if sys.stdin == sys.__stdin__
and
decides on that what to do. Since we aren't touching sys.stdin,
it goes ahead and uses low-level stuff from msvcrt to try and read. I think
it hangs at that point.

I think the solution is to check in ui.getpass if util.isatty(self.fin) or
something of that sort.
Please open a bug report so we can discuss this further.


>
> Beside that, how can client (my GUI) know when mercurial asks for
> something, that can be echoed (username) and when not (password) ?
> So, that I can hide password with '*'.
>
>
>             The second problem is that server needs a repository. I know
>>        that
>>            this is known limitation. But it is not possible to clone a
>>        remote
>>            repository in command server mode.
>>
>>
>>        I tried fixing this at some point, but it had too many edge
>>        cases to be
>>        worth the hassle.
>>
>>        What we do in python-hglib is run clone (or other non-repo
>>        commands) on
>>        the command line and then optionally connect to it using the
>>        cmdserver.
>>
>>
>>    How do you connect to it ?
>>    Using some command line switch to the command line client for clone
>>    command ?
>>
>>
>> No, we just do it in two separate commands, the first clones like usual
>> on the cmdline: `hg clone foo <path>`,
>> then start up the cmdserver on the new repo, `hg serve --cmdserver pipe
>> -R <path>`.
>>
>>
> Ok, I see.
> I hoped that it would be possible to write a GUI only solution with
> command server.


It is a bit unfortunate.

It might actually be possible to start the server without a repo and have
it stay "repo-less"
for its entire execution. What I tried in the past is to make it start
using a cached repo if
one appears later on in its repo path, say from a previous clone/init
command.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial/attachments/20111218/24e9141c/attachment.html>


More information about the Mercurial mailing list