Import upstream changes up to constabulary/gb@9e201fb
diff --git a/delete.go b/delete.go
index 9a0476c..13e9789 100644
--- a/delete.go
+++ b/delete.go
@@ -5,6 +5,8 @@
 	"fmt"
 	"path/filepath"
 
+	"github.com/constabulary/gb/fileutils"
+
 	"github.com/FiloSottile/gvt/gbvendor"
 )
 
@@ -59,7 +61,7 @@
 				return fmt.Errorf("dependency could not be deleted: %v", err)
 			}
 
-			if err := vendor.RemoveAll(filepath.Join(vendorDir(), filepath.FromSlash(path))); err != nil {
+			if err := fileutils.RemoveAll(filepath.Join(vendorDir(), filepath.FromSlash(path))); err != nil {
 				// TODO(dfc) need to apply vendor.cleanpath here to remove indermediate directories.
 				return fmt.Errorf("dependency could not be deleted: %v", err)
 			}
diff --git a/gbvendor/copy.go b/gbvendor/copy.go
index 52d4c98..f2d5d2c 100644
--- a/gbvendor/copy.go
+++ b/gbvendor/copy.go
@@ -6,6 +6,8 @@
 	"os"
 	"path/filepath"
 	"strings"
+
+	"github.com/constabulary/gb/fileutils"
 )
 
 const debugCopypath = true
@@ -42,7 +44,7 @@
 	})
 	if err != nil {
 		// if there was an error during copying, remove the partial copy.
-		RemoveAll(dst)
+		fileutils.RemoveAll(dst)
 	}
 	return err
 }
diff --git a/gbvendor/imports_test.go b/gbvendor/imports_test.go
index 37d029d..283f9db 100644
--- a/gbvendor/imports_test.go
+++ b/gbvendor/imports_test.go
@@ -2,6 +2,7 @@
 
 import (
 	"bytes"
+	"fmt"
 	"io"
 	"os"
 	"path/filepath"
@@ -134,10 +135,9 @@
 		importpath: "gopkg.in/mgo.v2",
 		vcs:        "git",
 		reporoot:   "https://gopkg.in/mgo.v2",
-		//	disabled: certificate has expired
-		//	}, {
-		//		path: "speter.net/go/exp",
-		//		err:  fmt.Errorf("go-import metadata not found"),
+	}, {
+		path: "speter.net/go/exp",
+		err:  fmt.Errorf("go-import metadata not found"),
 	}}
 
 	for _, tt := range tests {
diff --git a/gbvendor/manifest_test.go b/gbvendor/manifest_test.go
index 479f588..a2dc1f7 100644
--- a/gbvendor/manifest_test.go
+++ b/gbvendor/manifest_test.go
@@ -5,6 +5,8 @@
 	"os"
 	"path/filepath"
 	"testing"
+
+	"github.com/constabulary/gb/fileutils"
 )
 
 func mktemp(t *testing.T) string {
@@ -31,7 +33,7 @@
 
 func TestManifest(t *testing.T) {
 	root := mktemp(t)
-	defer RemoveAll(root)
+	defer fileutils.RemoveAll(root)
 
 	mf := filepath.Join(root, "vendor")
 
diff --git a/gbvendor/path.go b/gbvendor/path.go
deleted file mode 100644
index bb8334d..0000000
--- a/gbvendor/path.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package vendor
-
-import (
-	"os"
-	"path/filepath"
-	"runtime"
-)
-
-// RemoveAll removes path and any children it contains. Unlike os.RemoveAll it
-// deletes read only files on Windows.
-func RemoveAll(path string) error {
-	if runtime.GOOS == "windows" {
-		// Simple case: if Remove works, we're done.
-		err := os.Remove(path)
-		if err == nil || os.IsNotExist(err) {
-			return nil
-		}
-		// make sure all files are writable so we can delete them
-		filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
-			if err != nil {
-				// walk gave us some error, give it back.
-				return err
-			}
-			mode := info.Mode()
-			if mode|0200 == mode {
-				return nil
-			}
-			return os.Chmod(path, mode|0200)
-		})
-	}
-	return os.RemoveAll(path)
-}
diff --git a/gbvendor/repo.go b/gbvendor/repo.go
index 95393d6..5dbccd4 100644
--- a/gbvendor/repo.go
+++ b/gbvendor/repo.go
@@ -12,6 +12,8 @@
 	"path/filepath"
 	"regexp"
 	"strings"
+
+	"github.com/constabulary/gb/fileutils"
 )
 
 // RemoteRepo describes a remote dvcs repository.
@@ -323,7 +325,7 @@
 func (w workingcopy) Dir() string { return w.path }
 
 func (w workingcopy) Destroy() error {
-	if err := RemoveAll(w.path); err != nil {
+	if err := fileutils.RemoveAll(w.path); err != nil {
 		return err
 	}
 	parent := filepath.Dir(w.path)
@@ -380,18 +382,19 @@
 		"clone",
 		h.url,
 		dir,
+		"--noninteractive",
 	}
 
 	if branch != "" {
 		args = append(args, "--branch", branch)
 	}
 	if err := runOut(os.Stderr, "hg", args...); err != nil {
-		RemoveAll(dir)
+		fileutils.RemoveAll(dir)
 		return nil, err
 	}
 	if revision != "" {
 		if err := runOut(os.Stderr, "hg", "--cwd", dir, "update", "-r", revision); err != nil {
-			RemoveAll(dir)
+			fileutils.RemoveAll(dir)
 			return nil, err
 		}
 	}
@@ -449,7 +452,7 @@
 	}
 	wc := filepath.Join(dir, "wc")
 	if err := runOut(os.Stderr, "bzr", "branch", b.url, wc); err != nil {
-		RemoveAll(dir)
+		fileutils.RemoveAll(dir)
 		return nil, err
 	}
 
@@ -478,7 +481,7 @@
 		return nil
 	}
 	parent := filepath.Dir(path)
-	if err := RemoveAll(path); err != nil {
+	if err := fileutils.RemoveAll(path); err != nil {
 		return err
 	}
 	return cleanPath(parent)
@@ -500,6 +503,7 @@
 
 func runOut(w io.Writer, c string, args ...string) error {
 	cmd := exec.Command(c, args...)
+	cmd.Stdin = nil
 	cmd.Stdout = w
 	cmd.Stderr = os.Stderr
 	return cmd.Run()
@@ -514,6 +518,7 @@
 func runOutPath(w io.Writer, path string, c string, args ...string) error {
 	cmd := exec.Command(c, args...)
 	cmd.Dir = path
+	cmd.Stdin = nil
 	cmd.Stdout = w
 	cmd.Stderr = os.Stderr
 	return cmd.Run()
diff --git a/main.go b/main.go
index c95d30b..6245927 100644
--- a/main.go
+++ b/main.go
@@ -10,10 +10,7 @@
 var fs = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
 
 func init() {
-	fs.Usage = func() {
-		printUsage(os.Stderr)
-		os.Exit(2)
-	}
+	fs.Usage = usage
 }
 
 type Command struct {
@@ -38,8 +35,8 @@
 
 	switch {
 	case len(args) < 1, args[0] == "-h", args[0] == "-help":
-		fs.Usage()
-		os.Exit(1)
+		printUsage(os.Stdout)
+		os.Exit(0)
 	case args[0] == "help":
 		help(args[1:])
 		return
diff --git a/rebuild.go b/rebuild.go
index 87f13cd..0f523c2 100644
--- a/rebuild.go
+++ b/rebuild.go
@@ -9,6 +9,8 @@
 	"sync"
 	"sync/atomic"
 
+	"github.com/constabulary/gb/fileutils"
+
 	"github.com/FiloSottile/gvt/gbvendor"
 )
 
@@ -92,7 +94,7 @@
 func downloadDependency(dep vendor.Dependency) error {
 	dst := filepath.Join(vendorDir(), dep.Importpath)
 	if _, err := os.Stat(dst); err == nil {
-		if err := vendor.RemoveAll(dst); err != nil {
+		if err := fileutils.RemoveAll(dst); err != nil {
 			// TODO need to apply vendor.cleanpath here too
 			return fmt.Errorf("dependency could not be deleted: %v", err)
 		}
diff --git a/update.go b/update.go
index 86d0fb1..a719ced 100644
--- a/update.go
+++ b/update.go
@@ -5,6 +5,8 @@
 	"fmt"
 	"path/filepath"
 
+	"github.com/constabulary/gb/fileutils"
+
 	"github.com/FiloSottile/gvt/gbvendor"
 )
 
@@ -97,7 +99,7 @@
 				Path:       extra,
 			}
 
-			if err := vendor.RemoveAll(filepath.Join(vendorDir(), filepath.FromSlash(d.Importpath))); err != nil {
+			if err := fileutils.RemoveAll(filepath.Join(vendorDir(), filepath.FromSlash(d.Importpath))); err != nil {
 				// TODO(dfc) need to apply vendor.cleanpath here to remove intermediate directories.
 				return fmt.Errorf("dependency could not be deleted: %v", err)
 			}
diff --git a/vendor/github.com/constabulary/gb/fileutils/_testdata/copyfile/a/rick b/vendor/github.com/constabulary/gb/fileutils/_testdata/copyfile/a/rick
new file mode 120000
index 0000000..0db35ec
--- /dev/null
+++ b/vendor/github.com/constabulary/gb/fileutils/_testdata/copyfile/a/rick
@@ -0,0 +1 @@
+/never/going/to/give/you/up
\ No newline at end of file
diff --git a/vendor/github.com/constabulary/gb/fileutils/fileutils.go b/vendor/github.com/constabulary/gb/fileutils/fileutils.go
new file mode 100644
index 0000000..c2c2dc7
--- /dev/null
+++ b/vendor/github.com/constabulary/gb/fileutils/fileutils.go
@@ -0,0 +1,101 @@
+// package fileutils provides utililty methods to copy and move files and directories.
+package fileutils
+
+import (
+	"fmt"
+	"io"
+	"os"
+	"path/filepath"
+	"runtime"
+	"strings"
+)
+
+const debugCopypath = true
+const debugCopyfile = false
+
+// Copypath copies the contents of src to dst, excluding any file or
+// directory that starts with a period.
+func Copypath(dst string, src string) error {
+	err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
+		if err != nil {
+			return err
+		}
+
+		if strings.HasPrefix(filepath.Base(path), ".") {
+			if info.IsDir() {
+				return filepath.SkipDir
+			}
+			return nil
+		}
+
+		if info.IsDir() {
+			return nil
+		}
+
+		if info.Mode()&os.ModeSymlink != 0 {
+			if debugCopypath {
+				fmt.Printf("skipping symlink: %v\n", path)
+			}
+			return nil
+		}
+
+		dst := filepath.Join(dst, path[len(src):])
+		return copyfile(dst, path)
+	})
+	if err != nil {
+		// if there was an error during copying, remove the partial copy.
+		RemoveAll(dst)
+	}
+	return err
+}
+
+func copyfile(dst, src string) error {
+	err := mkdir(filepath.Dir(dst))
+	if err != nil {
+		return fmt.Errorf("copyfile: mkdirall: %v", err)
+	}
+	r, err := os.Open(src)
+	if err != nil {
+		return fmt.Errorf("copyfile: open(%q): %v", src, err)
+	}
+	defer r.Close()
+	w, err := os.Create(dst)
+	if err != nil {
+		return fmt.Errorf("copyfile: create(%q): %v", dst, err)
+	}
+	defer w.Close()
+	if debugCopyfile {
+		fmt.Printf("copyfile(dst: %v, src: %v)\n", dst, src)
+	}
+	_, err = io.Copy(w, r)
+	return err
+}
+
+// RemoveAll removes path and any children it contains. Unlike os.RemoveAll it
+// deletes read only files on Windows.
+func RemoveAll(path string) error {
+	if runtime.GOOS == "windows" {
+		// Simple case: if Remove works, we're done.
+		err := os.Remove(path)
+		if err == nil || os.IsNotExist(err) {
+			return nil
+		}
+		// make sure all files are writable so we can delete them
+		filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
+			if err != nil {
+				// walk gave us some error, give it back.
+				return err
+			}
+			mode := info.Mode()
+			if mode|0200 == mode {
+				return nil
+			}
+			return os.Chmod(path, mode|0200)
+		})
+	}
+	return os.RemoveAll(path)
+}
+
+func mkdir(path string) error {
+	return os.MkdirAll(path, 0755)
+}
diff --git a/gbvendor/copy_test.go b/vendor/github.com/constabulary/gb/fileutils/fileutils_test.go
similarity index 68%
rename from gbvendor/copy_test.go
rename to vendor/github.com/constabulary/gb/fileutils/fileutils_test.go
index 297d198..cfc40a2 100644
--- a/gbvendor/copy_test.go
+++ b/vendor/github.com/constabulary/gb/fileutils/fileutils_test.go
@@ -1,6 +1,7 @@
-package vendor
+package fileutils
 
 import (
+	"io/ioutil"
 	"path/filepath"
 	"runtime"
 	"testing"
@@ -17,3 +18,11 @@
 		t.Fatalf("copypath(%s, %s): %v", dst, src, err)
 	}
 }
+
+func mktemp(t *testing.T) string {
+	s, err := ioutil.TempDir("", "fileutils_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+	return s
+}
diff --git a/gbvendor/path_test.go b/vendor/github.com/constabulary/gb/fileutils/path_test.go
similarity index 98%
rename from gbvendor/path_test.go
rename to vendor/github.com/constabulary/gb/fileutils/path_test.go
index 2bba91b..1bdf9b1 100644
--- a/gbvendor/path_test.go
+++ b/vendor/github.com/constabulary/gb/fileutils/path_test.go
@@ -1,7 +1,7 @@
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
-package vendor
+package fileutils
 
 import (
 	"os"
diff --git a/vendor/manifest b/vendor/manifest
new file mode 100644
index 0000000..60981a3
--- /dev/null
+++ b/vendor/manifest
@@ -0,0 +1,12 @@
+{
+	"version": 0,
+	"dependencies": [
+		{
+			"importpath": "github.com/constabulary/gb/fileutils",
+			"repository": "https://github.com/constabulary/gb",
+			"revision": "9e201fb977e3dff7e0c94b73640be2a97285c418",
+			"branch": "master",
+			"path": "/fileutils"
+		}
+	]
+}
\ No newline at end of file