ananthakumaran/monky — pull request #9 by lyro (2011-11-08 14:21:49+00:00)
Title: Basic use of Mercurial's command server

Hi,

first, thank you for your great monky package.

When using monky I realized that for some operations it takes a lot of time. The reason seems to be that monky executes several mercurial commands during a single operation and the startup time of mercurial/python slows down the whole process considerably. For those purposes, when some external program needs to run several commands, the hg guys implemented the command server since version 1.9.

I implemented a basic approach using the command server. The idea is to execute hg commands within the scope of an `monky-with-process` block which spawn a single process in command-server mode and executes all commands within this context. I provide special versions for those commands that actually run the process namely `monky-cmdserver-process-file` and `monky-cmdserver-run*`.

In order to enable the command server on must customize the variable `monky-process-type` and set it to 'cmdserver (the default nil means to run the original versions of all commands without command server).

Currently only the synchronous commands are executed within the command server, all asynchronous commands still use the standard way.

On my machine the command server approach makes monky be much more responsive than before. On a repo with 13 unchanged files a simple update of the status buffer requires more than 4 seconds without the command server and less than one second with the command server.

It may even be possible to keep the command server running all the time which may improve the performance further, but then one may get problems when the repository is changed from outside emacs. I think the current approach is a good compromise.

Please let me know what you think of these changes.

Best regards,
Frank