Clear deprecation warnings
This fix clears deprecation warnings related to Nim's HashSet procedures. There were two types of warnings which have been fixed: - Warning: Deprecated since v0.20, use 'initHashSet'; initSet is deprecated [Deprecated] - Warning: Deprecated since v0.20, use 'toHashSet'; toSet is deprecated [Deprecated] Backward compatibility with older Nim versions is also implemented. Related to #680
This commit is contained in:
parent
2ec470d287
commit
db018f235b
5 changed files with 24 additions and 6 deletions
|
|
@ -94,7 +94,7 @@ proc copyFilesRec(origDir, currentDir, dest: string,
|
||||||
## Copies all the required files, skips files specified in the .nimble file
|
## Copies all the required files, skips files specified in the .nimble file
|
||||||
## (PackageInfo).
|
## (PackageInfo).
|
||||||
## Returns a list of filepaths to files which have been installed.
|
## Returns a list of filepaths to files which have been installed.
|
||||||
result = initSet[string]()
|
result = initHashSet[string]()
|
||||||
let whitelistMode =
|
let whitelistMode =
|
||||||
pkgInfo.installDirs.len != 0 or
|
pkgInfo.installDirs.len != 0 or
|
||||||
pkgInfo.installFiles.len != 0 or
|
pkgInfo.installFiles.len != 0 or
|
||||||
|
|
@ -373,7 +373,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
|
||||||
|
|
||||||
createDir(pkgDestDir)
|
createDir(pkgDestDir)
|
||||||
# Copy this package's files based on the preferences specified in PkgInfo.
|
# Copy this package's files based on the preferences specified in PkgInfo.
|
||||||
var filesInstalled = initSet[string]()
|
var filesInstalled = initHashSet[string]()
|
||||||
iterInstallFiles(realDir, pkgInfo, options,
|
iterInstallFiles(realDir, pkgInfo, options,
|
||||||
proc (file: string) =
|
proc (file: string) =
|
||||||
createDir(changeRoot(realDir, pkgDestDir, file.splitFile.dir))
|
createDir(changeRoot(realDir, pkgDestDir, file.splitFile.dir))
|
||||||
|
|
@ -386,7 +386,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
|
||||||
pkgInfo.myPath)
|
pkgInfo.myPath)
|
||||||
filesInstalled.incl copyFileD(pkgInfo.myPath, dest)
|
filesInstalled.incl copyFileD(pkgInfo.myPath, dest)
|
||||||
|
|
||||||
var binariesInstalled = initSet[string]()
|
var binariesInstalled = initHashSet[string]()
|
||||||
if pkgInfo.bin.len > 0:
|
if pkgInfo.bin.len > 0:
|
||||||
# Make sure ~/.nimble/bin directory is created.
|
# Make sure ~/.nimble/bin directory is created.
|
||||||
createDir(binDir)
|
createDir(binDir)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@
|
||||||
import terminal, sets, strutils
|
import terminal, sets, strutils
|
||||||
import version
|
import version
|
||||||
|
|
||||||
|
when not declared(initHashSet):
|
||||||
|
import common
|
||||||
|
|
||||||
type
|
type
|
||||||
CLI* = ref object
|
CLI* = ref object
|
||||||
level: Priority
|
level: Priority
|
||||||
|
|
@ -46,7 +49,7 @@ const
|
||||||
proc newCLI(): CLI =
|
proc newCLI(): CLI =
|
||||||
result = CLI(
|
result = CLI(
|
||||||
level: HighPriority,
|
level: HighPriority,
|
||||||
warnings: initSet[(string, string)](),
|
warnings: initHashSet[(string, string)](),
|
||||||
suppressionCount: 0,
|
suppressionCount: 0,
|
||||||
showColor: true,
|
showColor: true,
|
||||||
suppressMessages: false
|
suppressMessages: false
|
||||||
|
|
|
||||||
|
|
@ -63,3 +63,15 @@ when not defined(nimscript):
|
||||||
|
|
||||||
const
|
const
|
||||||
nimbleVersion* = "0.10.2"
|
nimbleVersion* = "0.10.2"
|
||||||
|
|
||||||
|
when not declared(initHashSet):
|
||||||
|
import sets
|
||||||
|
|
||||||
|
template initHashSet*[A](initialSize = 64): HashSet[A] =
|
||||||
|
initSet[A](initialSize)
|
||||||
|
|
||||||
|
when not declared(toHashSet):
|
||||||
|
import sets
|
||||||
|
|
||||||
|
template toHashSet*[A](keys: openArray[A]): HashSet[A] =
|
||||||
|
toSet(keys)
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ proc getPackage*(pkg: string, options: Options, resPkg: var Package): bool =
|
||||||
proc getPackageList*(options: Options): seq[Package] =
|
proc getPackageList*(options: Options): seq[Package] =
|
||||||
## Returns the list of packages found in the downloaded packages.json files.
|
## Returns the list of packages found in the downloaded packages.json files.
|
||||||
result = @[]
|
result = @[]
|
||||||
var namesAdded = initSet[string]()
|
var namesAdded = initHashSet[string]()
|
||||||
for name, list in options.config.packageLists:
|
for name, list in options.config.packageLists:
|
||||||
let packages = readPackageList(name, options)
|
let packages = readPackageList(name, options)
|
||||||
for p in packages:
|
for p in packages:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import os, strutils, sets, json
|
||||||
# Local imports
|
# Local imports
|
||||||
import version, cli, options, tools
|
import version, cli, options, tools
|
||||||
|
|
||||||
|
when not declared(initHashSet) or not declared(toHashSet):
|
||||||
|
import common
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
# This is just for Win XP support.
|
# This is just for Win XP support.
|
||||||
# TODO: Drop XP support?
|
# TODO: Drop XP support?
|
||||||
|
|
@ -103,4 +106,4 @@ proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision, nimbleLinkPath: string) =
|
||||||
## pkgDir - The directory where the original package files are.
|
## pkgDir - The directory where the original package files are.
|
||||||
## For example: ~/projects/jester/
|
## For example: ~/projects/jester/
|
||||||
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
||||||
toSet[string]([nimbleLinkPath]), initSet[string](), true)
|
toHashSet[string]([nimbleLinkPath]), initHashSet[string](), true)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue