grim/hgkeeper

8098dd6d3587
move KeysDir to a private variable in users.go
package hg
import (
"os"
"os/exec"
)
func common(cmd *exec.Cmd) *exec.Cmd {
cmd.Env = append(os.Environ(), "HGRCPATH=/dev/null")
return cmd
}
func Init(path string) *exec.Cmd {
return common(exec.Command("hg", "init", path))
}
func Serve(path string, writeable bool) *exec.Cmd {
args := []string{
"-R", path,
"serve",
"--stdio",
}
if !writeable {
args = append(args, "--config", "hooks.pretxnchangegroup=/bin/false")
}
return common(exec.Command("hg", args...))
}
func Add(path string, files ...string) *exec.Cmd {
args := append([]string{"add", "--cwd", path}, files...)
return common(exec.Command("hg", args...))
}
func Commit(path, username, message string) *exec.Cmd {
args := []string{
"commit",
"--cwd", path,
"--config", "ui.username=" + username,
"-m", message,
}
return common(exec.Command("hg", args...))
}