diff --git a/source/dub/dependency.d b/source/dub/dependency.d index bfab5f6..66cd3ca 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -3,7 +3,7 @@ Copyright: © 2012 Matthias Dondorff License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. - Authors: Matthias Dondorff + Authors: Matthias Dondorff, Sönke Ludwig */ module dub.dependency; @@ -52,45 +52,36 @@ size_t[] v; } - this(string vers) { - enforce( vers == MASTER_STRING || count(vers, ".") == 2); + this(string vers) + { + enforce(vers == MASTER_STRING || count(vers, ".") == 2); if(vers == MASTER_STRING) { - v = new size_t[3]; - v[0] = v[1] = v[2] = MASTER_VERS; - } - else { - string[] tkns = split(vers, "."); - v = new size_t[tkns.length]; - for(size_t i=0; i other.v[i] ) - return 1; - return 0; - } - - string toString() const { + string toString() + const { enforce( v.length == 3 && (v[0] != MASTER_VERS || v[1] == v[2] && v[1] == MASTER_VERS) ); if(v[0] == MASTER_VERS) return MASTER_STRING; @@ -107,6 +98,13 @@ /// compare methode, e.g. '>=1.0.0 <2.0.0' (i.e. a space separates the two /// version numbers) class Dependency { + private { + string m_cmpA; + Version m_versA; + string m_cmpB; + Version m_versB; + } + this( string ves ) { enforce( ves.length > 0); string orig = ves; @@ -151,6 +149,13 @@ } } } + + this(string cmp, string ver) + { + m_cmpA = cmp; + m_versB = m_versA = Version(ver); + m_cmpB = "=="; + } this(const Dependency o) { m_cmpA = o.m_cmpA; m_versA = Version(o.m_versA); @@ -162,8 +167,10 @@ override string toString() const { string r; // Special "==" case - if( m_versA == m_versB && m_cmpA == ">=" && m_cmpB == "<=" ) r = "==" ~ to!string(m_versA); - else { + if( m_versA == m_versB && m_cmpA == ">=" && m_cmpB == "<=" ){ + if( m_versA == Version.MASTER ) r = "~master"; + else r = "==" ~ to!string(m_versA); + } else { if( m_versA != Version.RELEASE ) r = m_cmpA ~ to!string(m_versA); if( m_versB != Version.HEAD ) r ~= (r.length==0?"" : " ") ~ m_cmpB ~ to!string(m_versB); if( m_versA == Version.RELEASE && m_versB == Version.HEAD ) r = ">=0.0.0"; @@ -225,7 +232,7 @@ private static string skipComp(ref string c) { size_t idx = 0; while( idx < c.length && !isDigit(c[idx]) ) idx++; - enforce( idx < c.length ); + enforce(idx < c.length, "Expected version number in version spec: "~c); string cmp = idx==c.length-1||idx==0? ">=" : c[0..idx]; c = c[idx..$]; switch(cmp) { @@ -245,13 +252,6 @@ default: enforce(false); return false; } } - - private { - string m_cmpA; - Version m_versA; - string m_cmpB; - Version m_versB; - } } unittest { diff --git a/source/dub/dub.d b/source/dub/dub.d index 14b20c2..8dd3f3e 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -3,7 +3,7 @@ Copyright: © 2012 Matthias Dondorff License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. - Authors: Matthias Dondorff + Authors: Matthias Dondorff, Sönke Ludwig */ module dub.dub; @@ -201,7 +201,7 @@ logDebug("Required package '"~pkg~"' found with version '"~p.vers~"'"); if( option & UpdateOptions.Reinstall ) { Dependency[string] em; - uninstalls ~= Action( Action.ActionId.Uninstall, pkg, new Dependency("==" ~ p.vers), em); + uninstalls ~= Action( Action.ActionId.Uninstall, pkg, new Dependency("==", p.vers), em); actions ~= Action(Action.ActionId.InstallUpdate, pkg, d.dependency, d.packages); } @@ -214,7 +214,7 @@ foreach( string pkg, p; unused ) { logDebug("Superfluous package found: '"~pkg~"', version '"~p.vers~"'"); Dependency[string] em; - uninstalls ~= Action( Action.ActionId.Uninstall, pkg, new Dependency("==" ~ p.vers), em); + uninstalls ~= Action( Action.ActionId.Uninstall, pkg, new Dependency("==", p.vers), em); } // Ugly "uninstall" comes first