aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.nim18
-rw-r--r--src/pacman.nim28
2 files changed, 40 insertions, 6 deletions
diff --git a/src/common.nim b/src/common.nim
index 58d4d08..a7d59c4 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -262,7 +262,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
check: HashSet[string]): HashSet[string] =
let full = results + check
- when NimVersion >= "1.2":
+ when NimVersion >= "1.3.5":
let direct = collect(newSeq):
for y in dependsTable.namedPairs:
if y.key in check:
@@ -274,6 +274,22 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
for x in providedBy:
if y.isProvidedBy(x.reference, true):
{x.name}
+ elif NimVersion >= "1.2":
+ let direct = block:
+ var tmp = newSeq[PackageReference]()
+ for y in dependsTable.namedPairs:
+ if y.key in check:
+ for x in y.value:
+ if withOptional or not x.optional:
+ tmp.add(x.reference)
+ tmp
+ let indirect = block:
+ var tmp = initHashSet[string]()
+ for y in direct:
+ for x in providedBy:
+ 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]
diff --git a/src/pacman.nim b/src/pacman.nim
index d1fadb0..1b9d2f9 100644
--- a/src/pacman.nim
+++ b/src/pacman.nim
@@ -300,15 +300,25 @@ proc checkConflicts*(args: seq[Argument],
let table = conflicts.obtainConflictsPairs
template full(s: string): OptionPair = table[s][0]
- when NimVersion >= "1.2":
- block:
- let tmp = collect(newSeq):
+ when NimVersion >= "1.3.5":
+ (block:collect(newSeq):
for c in conflicts:
if args.check(c.left.full):
for w in c.right:
if args.check(w.full):
(c.left,w)
- tmp.optFirst
+ ).optFirst
+ elif NimVersion >= "1.2":
+ (block:
+ var tmp = newSeq[(string,string)]()
+ for c in conflicts:
+ if args.check(c.left.full):
+ for w in c.right:
+ if args.check(w.full):
+ tmp.add((c.left,w))
+ tmp
+ ).optFirst
+
else:
lc[(c.left, w) | (c <- conflicts, args.check(c.left.full),
w <- c.right, args.check(w.full)), (string, string)].optFirst
@@ -340,12 +350,20 @@ proc pacmanRun*(root: bool, color: bool, args: varargs[Argument]): int =
proc pacmanValidateAndThrow(args: varargs[tuple[arg: Argument, pass: bool]]): void =
let argsSeq = @args
- when NimVersion >= "1.2":
+ when NimVersion >= "1.3.5":
let collectedArgs = collect(newSeq):
for y in argsSeq:
if y.pass:
for x in y.arg.collectArg:
x
+ elif NimVersion >= "1.2":
+ let collectedArgs = block:
+ var tmp = newSeq[string]()
+ for y in argsSeq:
+ if y.pass:
+ for x in y.arg.collectArg:
+ tmp.add(x)
+ tmp
else:
let collectedArgs = lc[x | (y <- argsSeq, y.pass, x <- y.arg.collectArg), string]
let code = forkWait(() => pacmanExecInternal(false, "-T" & collectedArgs))