Merge pull request #588 from Masterminds/fix/578

Fixed #578: Not resolving parent project packages in some cases
diff --git a/dependency/resolver.go b/dependency/resolver.go
index e237564..ddcb69d 100644
--- a/dependency/resolver.go
+++ b/dependency/resolver.go
@@ -483,7 +483,7 @@
 		}
 		r.VersionHandler.Process(dep)
 		// Here, we want to import the package and see what imports it has.
-		msg.Debug("Trying to open %s", vdep)
+		msg.Debug("Trying to open %s (%s)", dep, r.Handler.PkgPath(dep))
 		var imps []string
 		pkg, err := r.BuildContext.ImportDir(r.Handler.PkgPath(dep), 0)
 		if err != nil && strings.HasPrefix(err.Error(), "found packages ") {
@@ -621,6 +621,10 @@
 		t := r.Stripv(e.Value.(string))
 		root, sp := util.NormalizeName(t)
 
+		if root == r.Config.Name {
+			continue
+		}
+
 		// Skip ignored packages
 		if r.Config.HasIgnore(e.Value.(string)) {
 			msg.Debug("Ignoring: %s", e.Value.(string))
@@ -718,6 +722,10 @@
 		t := strings.TrimPrefix(e.Value.(string), r.VendorDir+string(os.PathSeparator))
 		root, sp := util.NormalizeName(t)
 
+		if root == r.Config.Name {
+			continue
+		}
+
 		existing := r.Config.Imports.Get(root)
 		if existing == nil && addTest {
 			existing = r.Config.DevImports.Get(root)
diff --git a/repo/installer.go b/repo/installer.go
index 324e4eb..52bc297 100644
--- a/repo/installer.go
+++ b/repo/installer.go
@@ -583,6 +583,12 @@
 func (m *MissingPackageHandler) PkgPath(pkg string) string {
 	root, sub := util.NormalizeName(pkg)
 
+	// For the parent applications source skip the cache.
+	if root == m.Config.Name {
+		pth := gpath.Basepath()
+		return filepath.Join(pth, filepath.FromSlash(sub))
+	}
+
 	d := m.Config.Imports.Get(root)
 	if d == nil {
 		d = m.Config.DevImports.Get(root)
@@ -601,7 +607,7 @@
 		msg.Die("Error generating cache key for %s", d.Name)
 	}
 
-	return filepath.Join(cache.Location(), "src", key, sub)
+	return filepath.Join(cache.Location(), "src", key, filepath.FromSlash(sub))
 }
 
 func (m *MissingPackageHandler) fetchToCache(pkg string, addTest bool) error {
@@ -767,6 +773,12 @@
 func (d *VersionHandler) pkgPath(pkg string) string {
 	root, sub := util.NormalizeName(pkg)
 
+	// For the parent applications source skip the cache.
+	if root == d.Config.Name {
+		pth := gpath.Basepath()
+		return filepath.Join(pth, filepath.FromSlash(sub))
+	}
+
 	dep := d.Config.Imports.Get(root)
 	if dep == nil {
 		dep = d.Config.DevImports.Get(root)
@@ -785,7 +797,7 @@
 		msg.Die("Error generating cache key for %s", dep.Name)
 	}
 
-	return filepath.Join(cache.Location(), "src", key, sub)
+	return filepath.Join(cache.Location(), "src", key, filepath.FromSlash(sub))
 }
 
 func determineDependency(v, dep *cfg.Dependency, dest, req string) *cfg.Dependency {