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
|
||||
## (PackageInfo).
|
||||
## Returns a list of filepaths to files which have been installed.
|
||||
result = initSet[string]()
|
||||
result = initHashSet[string]()
|
||||
let whitelistMode =
|
||||
pkgInfo.installDirs.len != 0 or
|
||||
pkgInfo.installFiles.len != 0 or
|
||||
|
|
@ -373,7 +373,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
|
|||
|
||||
createDir(pkgDestDir)
|
||||
# Copy this package's files based on the preferences specified in PkgInfo.
|
||||
var filesInstalled = initSet[string]()
|
||||
var filesInstalled = initHashSet[string]()
|
||||
iterInstallFiles(realDir, pkgInfo, options,
|
||||
proc (file: string) =
|
||||
createDir(changeRoot(realDir, pkgDestDir, file.splitFile.dir))
|
||||
|
|
@ -386,7 +386,7 @@ proc installFromDir(dir: string, requestedVer: VersionRange, options: Options,
|
|||
pkgInfo.myPath)
|
||||
filesInstalled.incl copyFileD(pkgInfo.myPath, dest)
|
||||
|
||||
var binariesInstalled = initSet[string]()
|
||||
var binariesInstalled = initHashSet[string]()
|
||||
if pkgInfo.bin.len > 0:
|
||||
# Make sure ~/.nimble/bin directory is created.
|
||||
createDir(binDir)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
import terminal, sets, strutils
|
||||
import version
|
||||
|
||||
when not declared(initHashSet):
|
||||
import common
|
||||
|
||||
type
|
||||
CLI* = ref object
|
||||
level: Priority
|
||||
|
|
@ -46,7 +49,7 @@ const
|
|||
proc newCLI(): CLI =
|
||||
result = CLI(
|
||||
level: HighPriority,
|
||||
warnings: initSet[(string, string)](),
|
||||
warnings: initHashSet[(string, string)](),
|
||||
suppressionCount: 0,
|
||||
showColor: true,
|
||||
suppressMessages: false
|
||||
|
|
|
|||
|
|
@ -63,3 +63,15 @@ when not defined(nimscript):
|
|||
|
||||
const
|
||||
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] =
|
||||
## Returns the list of packages found in the downloaded packages.json files.
|
||||
result = @[]
|
||||
var namesAdded = initSet[string]()
|
||||
var namesAdded = initHashSet[string]()
|
||||
for name, list in options.config.packageLists:
|
||||
let packages = readPackageList(name, options)
|
||||
for p in packages:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import os, strutils, sets, json
|
|||
# Local imports
|
||||
import version, cli, options, tools
|
||||
|
||||
when not declared(initHashSet) or not declared(toHashSet):
|
||||
import common
|
||||
|
||||
when defined(windows):
|
||||
# This is just for Win 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.
|
||||
## For example: ~/projects/jester/
|
||||
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