From bb4a490928aeb1b6d6cc50954da141b3cf0cacde Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Wed, 22 Feb 2012 15:39:53 -0500 Subject: [PATCH] builder: reuse existing workspace if possible R=golang-dev, bradfitz, rsc CC=golang-dev https://golang.org/cl/5690069 --- misc/dashboard/builder/main.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/misc/dashboard/builder/main.go b/misc/dashboard/builder/main.go index 5d0d6b2960d..4fe65b7a5d2 100644 --- a/misc/dashboard/builder/main.go +++ b/misc/dashboard/builder/main.go @@ -94,15 +94,19 @@ func main() { return } - // set up work environment - if err := os.RemoveAll(*buildroot); err != nil { - log.Fatalf("Error removing build root (%s): %s", *buildroot, err) - } - if err := os.Mkdir(*buildroot, mkdirPerm); err != nil { - log.Fatalf("Error making build root (%s): %s", *buildroot, err) - } - if err := hgClone(hgUrl, goroot); err != nil { - log.Fatal("Error cloning repository:", err) + // set up work environment, use existing enviroment if possible + if hgRepoExists(goroot) { + log.Print("Found old workspace, will use it") + } else { + if err := os.RemoveAll(*buildroot); err != nil { + log.Fatalf("Error removing build root (%s): %s", *buildroot, err) + } + if err := os.Mkdir(*buildroot, mkdirPerm); err != nil { + log.Fatalf("Error making build root (%s): %s", *buildroot, err) + } + if err := hgClone(hgUrl, goroot); err != nil { + log.Fatal("Error cloning repository:", err) + } } if *commitFlag {