aboutsummaryrefslogtreecommitdiff
path: root/src/common.nim
diff options
context:
space:
mode:
authorBenjamin Shirley-Quirk2020-08-05 01:14:46 +0000
committerBenjamin Shirley-Quirk2020-08-05 01:14:46 +0000
commit4bbf3dc2097f1de206fa053fac32f675d4ae2927 (patch)
tree721da2b78793860b6fb020194efe2eccea88bac9 /src/common.nim
parentcb63408d7d9de91020a7a815216b531fdf944b47 (diff)
factored out unnecessary NimVersions
Diffstat (limited to 'src/common.nim')
-rw-r--r--src/common.nim78
1 files changed, 27 insertions, 51 deletions
diff --git a/src/common.nim b/src/common.nim
index 0f2804b..f7de141 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -153,16 +153,12 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase],
return @[]
else:
if allowGroups and target.reference.constraint.isNone:
- when NimVersion >= "1.2":
- let groupRepo = optFirst:
- collect(newSeq):
- for d in dbs:
- for g in d.groups:
- if $g.name == target.reference.name:
- d
- else:
- let groupRepo = lc[d | (d <- dbs, g <- d.groups,
- $g.name == target.reference.name), ptr AlpmDatabase].optFirst
+ let groupRepo = optFirst:
+ collect(newSeq):
+ for d in dbs:
+ for g in d.groups:
+ if $g.name == target.reference.name:
+ d
if groupRepo.isSome:
return @[($groupRepo.unsafeGet.name, none(SyncFoundPackageInfo))]
@@ -248,14 +244,10 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
(installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives)
- when NimVersion >= "1.2":
- let providedBy = collect(newSeq):
- for x in alternatives.namedPairs:
- for y in x.value:
- (reference:y,name:x.key)
- else:
- let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value),
- tuple[reference: PackageReference, name: string]]
+ let providedBy = collect(newSeq):
+ for x in alternatives.namedPairs:
+ for y in x.value:
+ (reference:y,name:x.key)
proc findRequired(withOptional: bool, results: HashSet[string],
check: HashSet[string]): HashSet[string] =
@@ -273,7 +265,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
for x in providedBy:
if y.isProvidedBy(x.reference, true):
{x.name}
- elif NimVersion >= "1.2":
+ else:
let direct = block:
var tmp = newSeq[PackageReference]()
for y in dependsTable.namedPairs:
@@ -289,11 +281,6 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
if y.isProvidedBy(x.reference, true):
tmp.incl(x.name)
tmp
- else:
- let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check,
- x <- y.value, withOptional or not x.optional), PackageReference]
- let indirect = lc[x.name | (y <- direct, x <- providedBy,
- y.isProvidedBy(x.reference, true)), string].toHashSet
let checkNext = (direct.map(p => p.name).toHashSet + indirect) - full
if checkNext.len > 0: findRequired(withOptional, full, checkNext) else: full
@@ -664,29 +651,21 @@ proc obtainBuildPkgInfosInternal(config: Config, bases: seq[LookupBaseGroup],
(list[tuple[pkgInfos: seq[PackageInfo], path: Option[string]]](), 0))
let pkgInfosWithPaths = pkgInfosWithPathsReversed.reversed
- when NimVersion >= "1.2":
- let pkgInfos = collect(newSeq):
- for y in pkgInfosWithPaths:
- for x in y.pkgInfos:
- x
- let paths = collect(newSeq):
- for y in pkgInfosWithPaths:
- for x in y.path:
- x
- else:
- let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo]
- let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string]
+ let pkgInfos = collect(newSeq):
+ for y in pkgInfosWithPaths:
+ for x in y.pkgInfos:
+ x
+ let paths = collect(newSeq):
+ for y in pkgInfosWithPaths:
+ for x in y.path:
+ x
let pkgInfosTable = pkgInfos.map(i => (i.rpc.name, i)).toTable
- when NimVersion >= "1.2":
- let foundPkgInfos = collect(newSeq):
- for y in pacmanTargetNames:
- for x in pkgInfosTable.opt(y):
- x
- else:
- let foundPkgInfos = lc[x | (y <- pacmanTargetNames,
- x <- pkgInfosTable.opt(y)), PackageInfo]
+ let foundPkgInfos = collect(newSeq):
+ for y in pacmanTargetNames:
+ for x in pkgInfosTable.opt(y):
+ x
let errorMessages = pacmanTargetNames
.filter(n => not pkgInfosTable.hasKey(n))
.map(n => tr"$#: failed to get package info" % [n])
@@ -796,13 +775,10 @@ proc cloneAurReposWithPackageInfos*(config: Config, rpcInfos: seq[RpcPackageInfo
let (fullPkgInfos, paths, errors) = cloneNext(0, nil, nil, nil)
let pkgInfosTable = fullPkgInfos.map(i => (i.rpc.name, i)).toTable
- when NimVersion >= "1.2":
- let resultPkgInfos = collect(newSeq):
- for y in rpcInfos:
- for x in pkgInfosTable.opt(y.name):
- x
- else:
- let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo]
+ let resultPkgInfos = collect(newSeq):
+ for y in rpcInfos:
+ for x in pkgInfosTable.opt(y.name):
+ x
let names = rpcInfos.map(i => i.name).toHashSet
let additionalPkgInfos = fullPkgInfos.filter(i => not (i.rpc.name in names))