cmdserver: wrap 'pipe' mode server by service object

This is the stub for new mode that will listen for connections on unix domain
socket.

Though --daemon option is not banned in 'pipe' mode, it is useless because
the detached 'pipe' mode server exits immediately due to null stdin. Should
it abort if --daemon is specified with --cmdserver pipe or --stdio?
cmdserver: switch service objects by mode

server class will be changed to accept fin/fout pair instead of mode string
so that it can interact with socket files.
cmdserver: make server streams switchable

In 'unix' mode, server instance will be created per connection, and fin/fout
are set to socket files.
test-commandserver: remove unused repopath argument from check()

Instead of repopath, check() will receive connect() function as argument.
It will allow to connect to server of different mode.
test-commandserver: allow check() to make connection in different way

The next patch will add connector for 'unix' mode server.
test-commandserver: add connector for unix domain socket server

The next patch will introduce --cmdserver unix.
cmdserver: add service that listens on unix domain socket and forks process

Typical use case of 'unix' mode is a background hg daemon.

    $ hg serve --cmdserver unix --cwd / -a /tmp/hg-`id -u`.sock

Unlike 'pipe' mode in which parent process keeps stdio channel, 'unix' server
can be detached.  So clients can freely connect and disconnect from server,
saving Python start-up time.

It might be better to write "--cmdserver socket -a unix:/sockpath" instead
of "--cmdserver unix -a /sockpath" in case hgweb gets the ability to listen
on unix domain socket.