Make (install #head?) question more accurate.

This commit is contained in:
Dominik Picheta 2015-06-04 22:47:05 +01:00
commit 44a2b80a64
2 changed files with 19 additions and 7 deletions

View file

@ -667,7 +667,8 @@ proc install(packages: seq[PkgTuple],
except BuildFailed:
# The package failed to build.
# Check if we tried building a tagged version of the package.
if pv.ver.kind != verSpecial:
let headVer = parseVersionRange("#" & getHeadName(meth))
if pv.ver.kind != verSpecial and downloadVersion != headVer:
# If we tried building a tagged version of the package then
# ask the user whether they want to try building #head.
let promptResult = doPrompt and
@ -675,8 +676,8 @@ proc install(packages: seq[PkgTuple],
" like to try installing '$1@#head' (latest unstable)?") %
[pv.name, $downloadVersion])
if promptResult:
let verRange = parseVersionRange("#" & getHeadName(meth))
result = install(@[(pv.name, verRange)], options, doPrompt)
result = install(@[(pv.name, headVer)], options, doPrompt)
else:
raise newException(BuildFailed,
"Aborting installation due to build failure")

View file

@ -80,6 +80,17 @@ proc `==`*(spe: Special, spe2: Special): bool =
proc `<=`*(ver: Version, ver2: Version): bool =
return (ver == ver2) or (ver < ver2)
proc `==`*(range1: VersionRange, range2: VersionRange): bool =
if range1.kind != range2.kind : return false
result = case range1.kind
of verLater, verEarlier, verEqLater, verEqEarlier, verEq:
range1.ver == range2.ver
of verSpecial:
range1.spe == range2.spe
of verIntersect:
range1.verILeft == range2.verILeft and range1.verIRight == range2.verIRight
of verAny: true
proc withinRange*(ver: Version, ran: VersionRange): bool =
case ran.kind
of verLater: