workbench, settings: implement workbench reuse (i.e. single workbench window)
This patch adds a setting to enable/disable the creation of a "single workbench
instance". Rather than opening multiple workbench windows (which is slow if you
have a lot of repositories open), the first workbench that is created creates a
QLocalServer which listens to incoming connections.
When this setting is enabled, when the thg workbench is started it will first
try to connect to an existing "thg workbench server". If it cannot connect it
will assume that no other workbench is open, open the workbench window and start
a QLocalServer that will wait for connections from other thg clients. If it
successfully connects to an existing server, it will send the path of the
repository that must be open and exit. The server will receive this path and
open the corresponding repository in the existing workbench window.
A new setting "Single Workbench Window" has been added to the "Workbench"
panel. The default has been set to "False" for now. However, since this greatly
speeds up opening repositories in the workbench, I'd like to change it in the
future, once we add a way to open a new workbench even if this mode is enabled.
For now when this mode is enabled it is still possible to force TortoiseHg to
open a new window by using the new --newworkbench thg command line option.
In order to test it the best way is to enable the "Single Workbench mode" in the
settings, close TortoiseHg, and then open two console windows and run "thg
--nofork" on each of them.
For example, on the first console you could do:
> c:\Python26\python.exe thg --nofork
Then, on the second console you can execute thg and request to open a new repo
on the existing workbench window:
> c:\Python26\python.exe thg --nofork --repository c:\my_repo
At that point you should see the repository 'c:\my_repo' open on the
existing workbench window.