grim/hgkeeper

Add a caching layer to the hgweb portion. This should take some strain off of mercurial anf our cpu quota
package commands
import (
"fmt"
"path/filepath"
"github.com/gliderlabs/ssh"
log "github.com/sirupsen/logrus"
"bitbucket.org/rw_grim/hgkeeper/access"
"bitbucket.org/rw_grim/hgkeeper/hg"
)
type Init struct {
repoPath string
repoName string
}
func NewInit(reposPath, repoName string) *Init {
return &Init{
repoPath: filepath.Join(reposPath, repoName),
repoName: repoName,
}
}
func (i *Init) Run(session ssh.Session, username string) error {
if !access.CanInit(username, "/"+i.repoName) {
return fmt.Errorf("access denied")
}
if err := run(hg.Init(i.repoPath), session); err != nil {
return err
}
log.Info("refreshing access control for new repo")
return access.Refresh()
}