You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/12/28 01:28:06 UTC

[GitHub] ccollins476ad closed pull request #246: Discard duplicates in merged dep conditional

ccollins476ad closed pull request #246: Discard duplicates in merged dep conditional
URL: https://github.com/apache/mynewt-newt/pull/246
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index 46e6294f..c9ccb42d 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -234,6 +234,12 @@ func (r *Resolver) resolveDep(dep *pkg.Dependency,
 func (rpkg *ResolvePackage) AddDep(
 	depPkg *ResolvePackage, api string, expr string) bool {
 
+	norm, err := parse.NormalizeExpr(expr)
+	if err != nil {
+		panic("invalid expression, should have been caught earlier: " +
+			err.Error())
+	}
+
 	if dep := rpkg.Deps[depPkg]; dep != nil {
 		// This package already depends on dep.  If the conditional expression
 		// is new, or if the API string is different, then the existing
@@ -243,18 +249,11 @@ func (rpkg *ResolvePackage) AddDep(
 		// Determine if this is a new conditional expression.
 		oldExpr := dep.ExprString()
 
-		norm, err := parse.NormalizeExpr(expr)
-		if err != nil {
-			panic("invalid expression, should have been caught earlier: " +
-				err.Error())
-		}
-
-		dep.ExprMap[norm] = struct{}{}
-		merged := dep.ExprString()
-
 		changed := false
+		if _, ok := dep.ExprMap[norm]; !ok {
+			dep.ExprMap[norm] = struct{}{}
+			merged := dep.ExprString()
 
-		if oldExpr != merged {
 			log.Debugf("Package %s has conflicting dependencies on %s: "+
 				"old=`%s` new=`%s`; merging them into a single conditional: "+
 				"`%s`",
@@ -274,7 +273,7 @@ func (rpkg *ResolvePackage) AddDep(
 			Rpkg: depPkg,
 			Api:  api,
 			ExprMap: map[string]struct{}{
-				expr: struct{}{},
+				norm: struct{}{},
 			},
 		}
 	}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services