--- a/access/access.go Thu Apr 23 05:01:09 2020 -0500
+++ b/access/access.go Fri Apr 24 22:34:27 2020 -0500
@@ -29,7 +29,7 @@
adminRepoName = adminRepo
adminRepoPath = filepath.Join(reposPath, adminRepo)
- configPath, err := ioutil.TempFile("", "hgkeeper-hgweb-*.config")
+ configPath, err := ioutil.TempFile("", "hgkeeper-hgweb-access-*.config") @@ -75,7 +75,7 @@
- if err := refreshHgWeb(reposPath, adminRepoPath); err != nil {
+ if err := refreshHgWeb(reposPath); err != nil { --- a/access/hgweb.go Thu Apr 23 05:01:09 2020 -0500
+++ b/access/hgweb.go Fri Apr 24 22:34:27 2020 -0500
@@ -8,19 +8,13 @@
-func refreshHgWeb(reposPath, adminRepoPath string) error {
+func refreshHgWeb(reposPath string) error { fp, err := os.OpenFile(hgwebConfigPath, os.O_WRONLY|os.O_TRUNC, 0644)
- absAdminRepoPath, err := filepath.Abs(adminRepoPath)
- fmt.Fprintf(fp, "%%include %s\n\n", filepath.Join(absAdminRepoPath, "site.hgrc"))
fmt.Fprintf(fp, "[paths]\n")
absReposPath, err := filepath.Abs(reposPath)
--- a/hg/hg.go Thu Apr 23 05:01:09 2020 -0500
+++ b/hg/hg.go Fri Apr 24 22:34:27 2020 -0500
@@ -47,6 +47,15 @@
+func (c *Command) Exec() (string, error) { + raw, err := c.Cmd().CombinedOutput() + return string(raw), err func (c *Command) Cmd() *exec.Cmd {
@@ -84,3 +93,14 @@
cmd: exec.Command("hg", args...),
+func Config(setting string) *Command { + cmd: exec.Command("hg", args...), --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hgweb/files/hgweb.config Fri Apr 24 22:34:27 2020 -0500
@@ -0,0 +1,8 @@
+%include {{.HGWEB_ACCESS_CONFIG}} +# include the site config last as it should override everything --- a/hgweb/hgweb.go Thu Apr 23 05:01:09 2020 -0500
+++ b/hgweb/hgweb.go Fri Apr 24 22:34:27 2020 -0500
@@ -6,16 +6,20 @@
log "github.com/sirupsen/logrus"
"bitbucket.org/rw_grim/hgkeeper/access"
+ "bitbucket.org/rw_grim/hgkeeper/hg" @@ -31,6 +35,28 @@
+func (s *Server) createConfig() error { + configPath, err := ioutil.TempFile("", "hgkeeper-hgweb-*.config") + defer configPath.Close() + t := template.Must(template.New("hgweb-config").Parse(FSMustString(false, "/hgweb.config"))) + data := map[string]string{ + "HGWEB_ACCESS_CONFIG": access.HgwebConfigPath(), + "SITE_HGRC": filepath.Join(access.AdminRepoPath(), "site.hgrc"), + if err := t.Execute(configPath, data); err != nil { + s.configPath = configPath.Name() func (s *Server) createCGI() error {
cgiPath, err := ioutil.TempFile("", "hgkeeper-hgweb-*.cgi")
@@ -48,7 +74,7 @@
data := map[string]string{
- "HGWEB_CONFIG": access.HgwebConfigPath(),
+ "HGWEB_CONFIG": s.configPath, if err := t.Execute(cgiPath, data); err != nil {
@@ -61,6 +87,10 @@
func (s *Server) Listen() error {
+ if err := s.createConfig(); err != nil { if err := s.createCGI(); err != nil {
@@ -70,11 +100,19 @@
- s.server.Handler = Logger(
- &cgi.Handler{Path: s.cgiPath},
+ templatesDir, err := hg.TemplatesDir() + staticPath := filepath.Join(templatesDir, "static") + log.Infof("serving static files from %s", staticPath) + fileServer := http.FileServer(http.Dir(staticPath)) + mux := http.NewServeMux() + mux.Handle("/static/", http.StripPrefix("/static", fileServer)) + mux.Handle("/", &cgi.Handler{Path: s.cgiPath}) + s.server.Handler = Logger(cache.middleware(mux)) log.Infof("http listening on %s", s.listenAddr)
--- a/ssh/commands/run.go Thu Apr 23 05:01:09 2020 -0500
+++ b/ssh/commands/run.go Fri Apr 24 22:34:27 2020 -0500
@@ -16,6 +16,7 @@
if err := hgCmd.Setup(); err != nil {
stdout, err := cmd.StdoutPipe()