go.tools/dashboard/builder: use "hg archive -t files -r REV dest" instead of "hg clone" for the work directory.

It will save a lot of time for slow builders running on slow SD cards.

LGTM=dave, adg
R=golang-codereviews, dave, adg
CC=golang-codereviews
https://golang.org/cl/63550043
This commit is contained in:
Shenghou Ma 2014-02-13 20:50:29 -05:00
Родитель fac83ad60b
Коммит fa5c998c67
2 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -117,8 +117,11 @@ func (b *Builder) envvWindows() []string {
// and returns the path workpath/go/src, the location of all go build scripts.
func (env *goEnv) setup(repo *Repo, workpath, hash string, envv []string) (string, error) {
goworkpath := filepath.Join(workpath, "go")
if _, err := repo.Clone(goworkpath, hash); err != nil {
return "", fmt.Errorf("error cloning repository: %s", err)
if err := repo.Export(goworkpath, hash); err != nil {
return "", fmt.Errorf("error exporting repository: %s", err)
}
if err := ioutil.WriteFile(filepath.Join(goworkpath, "VERSION"), []byte(hash), 0644); err != nil {
return "", fmt.Errorf("error writing VERSION file: %s", err)
}
return filepath.Join(goworkpath, "src"), nil
}

Просмотреть файл

@ -61,6 +61,24 @@ func (r *Repo) Clone(path, rev string) (*Repo, error) {
}, nil
}
// Export exports the current Repo at revision rev to a new destination.
func (r *Repo) Export(path, rev string) error {
r.Lock()
defer r.Unlock()
downloadPath := r.Path
if !r.Exists() {
_, err := r.Clone(path, rev)
return err
}
args := []string{r.Master.VCS.Cmd, "archive", "-t", "files", "-r", rev, path}
if err := run(*cmdTimeout, nil, downloadPath, args...); err != nil {
return fmt.Errorf("executing %s: %v", strings.Join(args, " "), err)
}
return nil
}
// UpdateTo updates the working copy of this Repo to the
// supplied revision.
func (r *Repo) UpdateTo(hash string) error {