grim/hgkeeper

rework the ssh commands so there have a setup and teardown functions
package hg
import (
"os"
"os/exec"
)
type Command struct {
cmd *exec.Cmd
tmpHgrc string
writeable bool
}
func (c *Command) Setup() {
c.cmd.Env = append(os.Environ(), "HGRCPATH=/dev/null")
}
func (c *Command) Teardown() {
}
func (c *Command) Cmd() *exec.Cmd {
return c.cmd
}
func Init(path string) *Command {
return &Command{
cmd: exec.Command("hg", "init", path),
}
}
func Serve(path string, writeable bool) *Command {
return &Command{
cmd: exec.Command("hg", "-R", path, "serve", "--stdio"),
writeable: writeable,
}
}
func Add(path string, files ...string) *Command {
args := append([]string{"add", "--cwd", path}, files...)
return &Command{
cmd: exec.Command("hg", args...),
}
}
func Commit(path, username, message string) *Command {
args := []string{
"commit",
"--cwd", path,
"--config", "ui.username=" + username,
"-m", message,
}
return &Command{
cmd: exec.Command("hg", args...),
}
}