From 014b89771806deaa0bc7bd4a0fabebcbf1c871e6 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sun, 22 Jun 2014 17:08:07 +0100 Subject: [PATCH] Packages with URL dependencies are now removed properly. --- src/babel.nim | 19 ++++++++++++++----- src/babelpkg/download.nim | 5 ++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/babel.nim b/src/babel.nim index cef3d5a..b56abbb 100644 --- a/src/babel.nim +++ b/src/babel.nim @@ -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) diff --git a/src/babelpkg/download.nim b/src/babelpkg/download.nim index 89723fa..f69be8a 100644 --- a/src/babelpkg/download.nim +++ b/src/babelpkg/download.nim @@ -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.} =