grim/hgkeeper

f70ee21d6c1c
Rename the --disable-http serve flag to --disable-hgweb.

The HTTP interface will be required going forward.
package hg
import (
"fmt"
"os/exec"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
)
func TemplatesDir() (string, error) {
templatesDir, err := Config("web.templates").Exec("", "")
if err != nil || templatesDir == "" {
if err != nil {
log.Warnf("failed to read web.templates setting from hg: %v", err)
}
args := []string{
"/usr/bin/env",
"python3",
"-c",
"import mercurial;print(mercurial.__path__[0])",
}
cmd := exec.Command(args[0], args[1:]...)
raw, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
templatesDir = strings.TrimSpace(string(raw))
if templatesDir == "" {
return "", fmt.Errorf("failed to find the templates directory")
}
templatesDir = filepath.Join(templatesDir, "templates")
}
return templatesDir, nil
}