Reverse deps no longer added in one incorrect case.
This commit is contained in:
parent
35fef81b66
commit
509eff97a3
3 changed files with 25 additions and 9 deletions
|
|
@ -288,6 +288,9 @@ proc copyFilesRec(origDir, currentDir, dest: string,
|
|||
result.incl copyFileD(pkgInfo.mypath,
|
||||
changeRoot(pkgInfo.mypath.splitFile.dir, dest, pkgInfo.mypath))
|
||||
|
||||
proc saveBabelData(options: TOptions) =
|
||||
writeFile(options.getBabelDir() / "babeldata.json", pretty(options.babelData))
|
||||
|
||||
proc addRevDep(options: TOptions, dep: tuple[name, version: string],
|
||||
pkg: TPackageInfo) =
|
||||
let depNameVer = dep.name & '-' & dep.version
|
||||
|
|
@ -300,8 +303,6 @@ proc addRevDep(options: TOptions, dep: tuple[name, version: string],
|
|||
if revDep notin thisDep:
|
||||
thisDep.add revDep
|
||||
|
||||
writeFile(options.getBabelDir() / "babeldata.json", pretty(options.babelData))
|
||||
|
||||
proc removeRevDep(options: TOptions, pkg: TPackageInfo) =
|
||||
## Removes ``pkg`` from the reverse dependencies of every package.
|
||||
proc remove(options: TOptions, pkg: TPackageInfo, depTup: TPkgTuple,
|
||||
|
|
@ -337,7 +338,7 @@ proc removeRevDep(options: TOptions, pkg: TPackageInfo) =
|
|||
newData[key] = newVal
|
||||
options.babelData["reverseDeps"] = newData
|
||||
|
||||
writeFile(options.getBabelDir() / "babeldata.json", pretty(options.babelData))
|
||||
saveBabelData(options)
|
||||
|
||||
proc install(packages: seq[tuple[name: string, verRange: PVersionRange]],
|
||||
options: TOptions,
|
||||
|
|
@ -348,6 +349,7 @@ proc processDeps(pkginfo: TPackageInfo, options: TOptions): seq[string] =
|
|||
## Returns the list of paths to pass to the compiler during build phase.
|
||||
result = @[]
|
||||
let pkglist = getInstalledPkgs(options.getPkgsDir())
|
||||
var reverseDeps: seq[tuple[name, version: string]] = @[]
|
||||
for dep in pkginfo.requires:
|
||||
if dep.name == "nimrod":
|
||||
let nimVer = getNimrodVersion()
|
||||
|
|
@ -367,7 +369,7 @@ proc processDeps(pkginfo: TPackageInfo, options: TOptions): seq[string] =
|
|||
result.add(pkg.mypath.splitFile.dir)
|
||||
# Process the dependencies of this dependency.
|
||||
result.add(processDeps(pkg, options))
|
||||
addRevDep(options, (pkg.name, pkg.version), pkginfo)
|
||||
reverseDeps.add((pkg.name, pkg.version))
|
||||
|
||||
# Check if two packages of the same name (but different version) are listed
|
||||
# in the path.
|
||||
|
|
@ -380,6 +382,13 @@ proc processDeps(pkginfo: TPackageInfo, options: TOptions): seq[string] =
|
|||
[name, version, pkgsInPath[name]])
|
||||
pkgsInPath[name] = version
|
||||
|
||||
# We add the reverse deps to the JSON file here because we don't want
|
||||
# them added if the above errorenous condition occurs
|
||||
# (unsatisfiable dependendencies).
|
||||
for i in reverseDeps:
|
||||
addRevDep(options, i, pkginfo)
|
||||
saveBabelData(options)
|
||||
|
||||
proc buildFromDir(pkgInfo: TPackageInfo, paths: seq[string]) =
|
||||
## Builds a package as specified by ``pkgInfo``.
|
||||
let realDir = pkgInfo.getRealDir()
|
||||
|
|
|
|||
|
|
@ -287,7 +287,8 @@ proc findPkg*(pkglist: seq[tuple[pkginfo: TPackageInfo, meta: TMetaData]],
|
|||
##
|
||||
## **Note**: dep.name here could be a URL, hence the need for pkglist.meta.
|
||||
for pkg in pkglist:
|
||||
if pkg.pkginfo.name != dep.name and pkg.meta.url != dep.name: continue
|
||||
if pkg.pkginfo.name.normalize != dep.name.normalize and
|
||||
pkg.meta.url.normalize != dep.name.normalize: continue
|
||||
if withinRange(newVersion(pkg.pkginfo.version), dep.ver):
|
||||
if not result or newVersion(r.version) < newVersion(pkg.pkginfo.version):
|
||||
r = pkg.pkginfo
|
||||
|
|
@ -300,7 +301,8 @@ proc findAllPkgs*(pkglist: seq[tuple[pkginfo: TPackageInfo, meta: TMetaData]],
|
|||
## packages if multiple are found.
|
||||
result = @[]
|
||||
for pkg in pkglist:
|
||||
if pkg.pkginfo.name != dep.name and pkg.meta.url != dep.name: continue
|
||||
if pkg.pkginfo.name.normalize != dep.name.normalize and
|
||||
pkg.meta.url.normalize != dep.name.normalize: continue
|
||||
if withinRange(newVersion(pkg.pkginfo.version), dep.ver):
|
||||
result.add pkg.pkginfo
|
||||
|
||||
|
|
|
|||
|
|
@ -58,18 +58,23 @@ test "can uninstall":
|
|||
|
||||
check execCmdEx(path & " uninstall -y issue27").exitCode == QuitSuccess
|
||||
check execCmdEx(path & " uninstall -y issue27a").exitCode == QuitSuccess
|
||||
check execCmdEx(path & " uninstall -y issue27b").exitCode == QuitSuccess
|
||||
|
||||
# Remove Package*
|
||||
check execCmdEx(path & " uninstall -y PackageA@0.5").exitCode == QuitSuccess
|
||||
|
||||
let (outp, exitCode) = execCmdEx(path & " uninstall -y PackageA")
|
||||
check exitCode != QuitSuccess
|
||||
let ls = outp.processOutput()
|
||||
check ls[ls.len-3].startsWith(" Cannot uninstall PackageA ")
|
||||
check ls[ls.len-2].startsWith(" Cannot uninstall PackageA ")
|
||||
check ls[ls.len-1].startsWith(" Cannot uninstall PackageA ")
|
||||
check execCmdEx(path & " uninstall -y PackageBin2").exitCode == QuitSuccess
|
||||
|
||||
# Case insensitive
|
||||
check execCmdEx(path & " uninstall -y packagea").exitCode == QuitSuccess
|
||||
|
||||
check execCmdEx(path & " uninstall -y PackageA").exitCode != QuitSuccess
|
||||
|
||||
# Remove the rest of the installed packages.
|
||||
check execCmdEx(path & " uninstall -y PackageB").exitCode == QuitSuccess
|
||||
|
||||
check execCmdEx(path & " uninstall -y PackageA@0.2 issue27b").exitCode == QuitSuccess
|
||||
check (not dirExists(getHomeDir() / ".babel" / "pkgs" / "PackageA-0.2.0"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue