Command server

Sergey Antonov sergant_ at mail.ru
Sun Dec 18 13:55:40 UTC 2011


On 18.12.2011 17:09, Idan Kamara wrote:
> On Sun, Dec 18, 2011 at 1:50 PM, Sergey Antonov <sergant_ at mail.ru
> <mailto: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>
>         <mailto: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.
>

I've opened a bug report:
http://mercurial.selenic.com/bts/issue3161

>
>                     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.

Maybe it is possible to add a global switch for the commands, that may 
create a repository (init, clone), that will run these commands in 
command server mode ?

Something like "hg init --cmdserver pipe", which run this in command 
server mode and if the result is successful (repository created), then 
it will use it for subsequent commands. And if the command is not 
successful, then it will abort.

-- 
Sergey Antonov
sergant_ at mail.ru



More information about the Mercurial mailing list