}
try {
session = conn.openSession();
final String path = uri.getPath();
session.execCommand(String.format("hg -R %s serve --stdio", path.charAt(0) == '/' ? path.substring(1) : path));
remoteErr = new StreamGobbler(session.getStderr());
remoteOut = new StreamGobbler(session.getStdout());
remoteIn = session.getStdin();
sessionUse = 1;
} catch (IOException ex) {
throw new HgRemoteConnectionException("Failed to create ssh session", ex);
}