package getter
import (
+ "context"
"fmt"
"net/url"
"os"
"runtime"
urlhelper "github.com/hashicorp/go-getter/helper/url"
- "github.com/hashicorp/go-safetemp"
+ safetemp "github.com/hashicorp/go-safetemp"
)
// HgGetter is a Getter implementation that will download a module from
// a Mercurial repository.
-type HgGetter struct{}
+type HgGetter struct {
+ getter
+}
func (g *HgGetter) ClientMode(_ *url.URL) (ClientMode, error) {
return ClientModeDir, nil
}
func (g *HgGetter) Get(dst string, u *url.URL) error {
+ ctx := g.Context()
if _, err := exec.LookPath("hg"); err != nil {
return fmt.Errorf("hg must be available and on the PATH")
}
return err
}
- return g.update(dst, newURL, rev)
+ return g.update(ctx, dst, newURL, rev)
}
// GetFile for Hg doesn't support updating at this time. It will download
return err
}
- fg := &FileGetter{Copy: true}
+ fg := &FileGetter{Copy: true, getter: g.getter}
return fg.GetFile(dst, u)
}
return getRunCommand(cmd)
}
-func (g *HgGetter) update(dst string, u *url.URL, rev string) error {
+func (g *HgGetter) update(ctx context.Context, dst string, u *url.URL, rev string) error {
args := []string{"update"}
if rev != "" {
args = append(args, rev)
}
- cmd := exec.Command("hg", args...)
+ cmd := exec.CommandContext(ctx, "hg", args...)
cmd.Dir = dst
return getRunCommand(cmd)
}