Packages with URL dependencies are now removed properly.

This commit is contained in:
Dominik Picheta 2014-06-22 17:08:07 +01:00
commit 014b897718
2 changed files with 18 additions and 6 deletions

View file

@ -304,9 +304,8 @@ proc addRevDep(options: TOptions, dep: tuple[name, version: string],
proc removeRevDep(options: TOptions, pkg: TPackageInfo) =
## Removes ``pkg`` from the reverse dependencies of every package.
for depTup in pkg.requires:
let thisDep = options.babelData["reverseDeps"][depTup.name]
if thisDep.isNil: continue
proc remove(options: TOptions, pkg: TPackageInfo, depTup: TPkgTuple,
thisDep: PJsonNode) =
for ver, val in thisDep:
if ver.newVersion in depTup.ver:
var newVal = newJArray()
@ -314,7 +313,17 @@ proc removeRevDep(options: TOptions, pkg: TPackageInfo) =
if not (revDep["name"].str == pkg.name and
revDep["version"].str == pkg.version):
newVal.add revDep
options.babelData["reverseDeps"][depTup.name][ver] = newVal
thisDep[ver] = newVal
for depTup in pkg.requires:
if depTup.name.isURL():
# We sadly must go through everything in this case...
for key, val in options.babelData["reverseDeps"]:
options.remove(pkg, depTup, val)
else:
let thisDep = options.babelData["reverseDeps"][depTup.name]
if thisDep.isNil: continue
options.remove(pkg, depTup, thisDep)
writeFile(options.getBabelDir() / "babeldata.json", pretty(options.babelData))
@ -523,7 +532,7 @@ proc install(packages: seq[tuple[name: string, verRange: PVersionRange]],
# Install each package.
for pv in packages:
if pv.name.startsWith(peg" @'://' "):
if pv.name.isURL:
let meth = checkUrlType(pv.name)
let downloadDir = downloadPkg(pv.name, pv.verRange, meth)
result = installFromDir(downloadDir, false, options, pv.name)

View file

@ -1,7 +1,7 @@
# Copyright (C) Dominik Picheta. All rights reserved.
# BSD License. Look at license.txt for more info.
import parseutils, os, osproc, strutils, tables
import parseutils, os, osproc, strutils, tables, pegs
import packageinfo, version, tools
@ -129,6 +129,9 @@ proc checkUrlType*(url: string): TDownloadMethod =
else:
raise newException(EBabel, "Unable to identify url.")
proc isURL*(name: string): bool =
name.startsWith(peg" @'://' ")
proc doDownload*(url: string, downloadDir: string, verRange: PVersionRange,
downMethod: TDownloadMethod) =
template getLatestByTag(meth: stmt): stmt {.dirty, immediate.} =