From edcec4ecdf908b5eed1a930a821980e095acd60b Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Tue, 27 Nov 2012 11:56:19 +0100 Subject: [PATCH] use a Selection for the 'search' command so that the repofilter works --- examples/pysolv | 11 +++++++---- examples/solv.c | 28 ++++++++++++++++------------ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/examples/pysolv b/examples/pysolv index 0bdf8e0..0036dbe 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -642,12 +642,15 @@ if options.repos: repolimiter.add_raw(Job.SOLVER_SOLVABLE_REPO|Job.SOLVER_SETREPO|Job.SOLVER_SETVENDOR, repo.handle.id) if cmd == 'search': - matches = {} + pool.createwhatprovides() + sel = pool.Selection() di = pool.Dataiterator(0, solv.SOLVABLE_NAME, args[0], Dataiterator.SEARCH_SUBSTRING|Dataiterator.SEARCH_NOCASE) for d in di: - matches[d.solvid] = True - for solvid in sorted(matches.keys()): - print " - %s [%s]: %s" % (pool.solvid2str(solvid), pool.solvables[solvid].repo.name, pool.lookup_str(solvid, solv.SOLVABLE_SUMMARY)) + sel.add_raw(Job.SOLVER_SOLVABLE, d.solvid) + if repolimiter: + sel.limit(repolimiter) + for s in sel.solvables(): + print " - %s [%s]: %s" % (s, s.repo.name, s.lookup_str(solv.SOLVABLE_SUMMARY)) sys.exit(0) cmdlinerepo = None diff --git a/examples/solv.c b/examples/solv.c index 7ca9729..9c9510f 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -2591,34 +2591,38 @@ main(int argc, char **argv) } if (mainmode == MODE_SEARCH) { + Queue sel, q; Dataiterator di; - Map m; if (argc != 2) usage(1); - map_init(&m, pool->nsolvables); + pool_createwhatprovides(pool); + queue_init(&sel); dataiterator_init(&di, pool, 0, 0, 0, argv[1], SEARCH_SUBSTRING|SEARCH_NOCASE); dataiterator_set_keyname(&di, SOLVABLE_NAME); dataiterator_set_search(&di, 0, 0); while (dataiterator_step(&di)) - MAPSET(&m, di.solvid); + queue_push2(&sel, SOLVER_SOLVABLE, di.solvid); dataiterator_set_keyname(&di, SOLVABLE_SUMMARY); dataiterator_set_search(&di, 0, 0); while (dataiterator_step(&di)) - MAPSET(&m, di.solvid); + queue_push2(&sel, SOLVER_SOLVABLE, di.solvid); dataiterator_set_keyname(&di, SOLVABLE_DESCRIPTION); dataiterator_set_search(&di, 0, 0); while (dataiterator_step(&di)) - MAPSET(&m, di.solvid); + queue_push2(&sel, SOLVER_SOLVABLE, di.solvid); dataiterator_free(&di); - - for (p = 1; p < pool->nsolvables; p++) + if (repofilter.count) + selection_limit(pool, &sel, &repofilter); + + queue_init(&q); + selection_solvables(pool, &sel, &q); + queue_free(&sel); + for (i = 0; i < q.count; i++) { - Solvable *s = pool_id2solvable(pool, p); - if (!MAPTST(&m, p)) - continue; - printf(" - %s: %s\n", pool_solvable2str(pool, s), solvable_lookup_str(s, SOLVABLE_SUMMARY)); + Solvable *s = pool_id2solvable(pool, q.elements[i]); + printf(" - %s [%s]: %s\n", pool_solvable2str(pool, s), s->repo->name, solvable_lookup_str(s, SOLVABLE_SUMMARY)); } - map_free(&m); + queue_free(&q); exit(0); } -- 2.7.4