You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/01/16 00:26:00 UTC

[mynewt-newt] 01/02: newt upgrade: Fix repo conflict error message

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 56eafd01c2b4adba9d7e680bf09f74832e14ba4f
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Jan 14 17:11:01 2020 -0800

    newt upgrade: Fix repo conflict error message
    
    If a `newt upgrade` operation fails due to conflicting repo
    requirements, the error message should indicate which requirements are
    in conflict.  The bug was that the error message was missing "root
    requirements" (requirements specified in project.yml), so the message
    was incomplete.
    
    For example (before fix):
    
        Error: Repository conflicts:
            Installation of repo "mynewt-dummy-repo-04" is blocked:
                mynewt-dummy-repo-01,1.0.0 requires mynewt-dummy-repo-04 ==1.0.0
    
    After fix:
    
        Error: Repository conflicts:
            Installation of repo "mynewt-dummy-repo-04" is blocked:
                               project.yml requires mynewt-dummy-repo-04 ==1.0.2/0eaf06337c8f8dc8c49fffa884a6a0c2fb223d73
                mynewt-dummy-repo-01,1.0.0 requires mynewt-dummy-repo-04 ==1.0.0
---
 newt/deprepo/deprepo.go | 21 +++++++++++++--------
 newt/install/install.go |  9 +++++++--
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/newt/deprepo/deprepo.go b/newt/deprepo/deprepo.go
index f42a5d7..e518e26 100644
--- a/newt/deprepo/deprepo.go
+++ b/newt/deprepo/deprepo.go
@@ -238,15 +238,20 @@ func PruneMatrix(m *Matrix, repos RepoMap, rootReqs RequirementMap) error {
 // of repos in the project.
 func PruneDepGraph(dg DepGraph, keep []*repo.Repo) {
 	for k, _ := range dg {
-		found := false
-		for _, r := range keep {
-			if r.Name() == k.Name {
-				found = true
-				break
+		// The empty string indicates a `project.yml` requirement.  Always
+		// keep these.
+		if k.Name != "" {
+			found := false
+
+			for _, r := range keep {
+				if k.Name == r.Name() {
+					found = true
+					break
+				}
+			}
+			if !found {
+				delete(dg, k)
 			}
-		}
-		if !found {
-			delete(dg, k)
 		}
 	}
 }
diff --git a/newt/install/install.go b/newt/install/install.go
index ef3d18f..c25cfd1 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -670,8 +670,13 @@ func (inst *Installer) calcVersionMap(candidates []*repo.Repo) (
 	for name, nodes := range rg {
 		for _, node := range nodes {
 			if newtutil.CompareRepoVersions(node.Ver, vm[node.Name]) == 0 {
-				if err := inst.assignCommits(vm, name, node.VerReqs, false); err != nil {
-					return nil, err
+				// Don't consider project.yml dependencies here.  Those get
+				// assigned last so that they can override inter-repo
+				// dependencies.
+				if node.Name != "" {
+					if err := inst.assignCommits(vm, name, node.VerReqs, false); err != nil {
+						return nil, err
+					}
 				}
 			}
 		}