Skip to content

Commit 970836d

Browse files
committed
simplify and remove logs
1 parent 36c0871 commit 970836d

1 file changed

Lines changed: 31 additions & 85 deletions

File tree

src/policy.c

Lines changed: 31 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,6 @@ prune_to_best_version_sortcmp(const void *ap, const void *bp, void *dp)
7878
}
7979
/* sort by repository sub-prio (installed repo handled above) */
8080
r = (sb->repo ? sb->repo->subpriority : 0) - (sa->repo ? sa->repo->subpriority : 0);
81-
#ifdef ENABLE_CONDA
82-
if (r == 0)
83-
{
84-
Repodata* ra = repo_last_repodata(sa->repo);
85-
Repodata* rb = repo_last_repodata(sb->repo);
86-
87-
unsigned long long bta = repodata_lookup_num(ra, a, SOLVABLE_BUILDTIME, 0ull);
88-
unsigned long long btb = repodata_lookup_num(rb, b, SOLVABLE_BUILDTIME, 0ull);
89-
r = bta - btb;
90-
}
91-
#endif
9281
if (r)
9382
return r;
9483
/* no idea about the order, sort by id */
@@ -990,33 +979,13 @@ int check_deps_unequal(Pool* pool, Queue* q1, Queue* q2, Id name)
990979
{
991980
Id h1 = 0, h2 = 0;
992981
int i;
993-
Id elem;
994982

995-
// TODO check if reldep ID is equal if same reldep
996-
Reldep* rdep;
997983
for (i = 0; i < q1->count; ++i)
998-
{
999-
elem = q1->elements[i];
1000-
if (!ISRELDEP(elem)) continue;
1001-
rdep = GETRELDEP(pool, elem);
1002-
1003-
if (rdep->name == name)
1004-
{
1005-
h1 ^= rdep->evr;
1006-
}
1007-
}
984+
h1 ^= q1->elements[i];
1008985

1009986
for (i = 0; i < q2->count; ++i)
1010-
{
1011-
elem = q2->elements[i];
1012-
if (!ISRELDEP(elem)) continue;
1013-
rdep = GETRELDEP(pool, elem);
987+
h2 ^= q2->elements[i];
1014988

1015-
if (rdep->name == name)
1016-
{
1017-
h2 ^= rdep->evr;
1018-
}
1019-
}
1020989
return h1 != h2;
1021990
}
1022991

@@ -1051,10 +1020,7 @@ Id best_matching(Pool* pool, Queue* q, Id name, int* all_have_trackfeatures)
10511020
}
10521021

10531022
if (selection.count == 0)
1054-
{
1055-
// no matches found ...
10561023
return 0;
1057-
}
10581024

10591025
Solvable* best = pool_id2solvable(pool, selection.elements[0]), *stmp;
10601026
int cmp;
@@ -1072,10 +1038,6 @@ Id best_matching(Pool* pool, Queue* q, Id name, int* all_have_trackfeatures)
10721038
{
10731039
stmp = pool_id2solvable(pool, selection.elements[i]);
10741040
cmp = pool_evrcmp(pool, best->evr, stmp->evr, 0);
1075-
// printf("Comparing: %s vs %s: %d\n",
1076-
// pool_id2str(pool, best->evr),
1077-
// pool_id2str(pool, stmp->evr),
1078-
// cmp);
10791041
if (cmp < 0) best = stmp;
10801042
}
10811043

@@ -1087,8 +1049,6 @@ int conda_compare_dependencies(Pool *pool, Solvable *s1, Solvable *s2)
10871049
int i, j, has_seen;
10881050
Queue q1, q2, seen;
10891051

1090-
// queue_init(&pkgs_a);
1091-
// queue_init(&pkgs_b);
10921052
queue_init(&q1);
10931053
queue_init(&q2);
10941054
queue_init(&seen);
@@ -1104,66 +1064,41 @@ int conda_compare_dependencies(Pool *pool, Solvable *s1, Solvable *s2)
11041064
has_seen = 0;
11051065

11061066
if (!ISRELDEP(x1))
1107-
{
11081067
continue;
1109-
}
11101068

11111069
Reldep* rd1 = GETRELDEP(pool, x1);
11121070
for (j = 0; j < seen.count && has_seen == 0; ++j)
1113-
{
11141071
if (seen.elements[i] == rd1->name)
11151072
has_seen = 1;
1116-
}
1117-
printf("Has seen: %d\n", has_seen);
11181073

11191074
if (has_seen)
1120-
{
1121-
continue;
1122-
}
1075+
continue;
11231076

11241077
// first make sure that deps are different between a & b
11251078
int deps_unequal = check_deps_unequal(pool, &q1, &q2, rd1->name);
1126-
printf("Deps are unequal: %d\n", deps_unequal);
1127-
fflush(stdout);
1128-
if (1)
1129-
{
1130-
int ii;
1131-
for (ii = 0; ii < q1.count; ++ii)
1132-
{
1133-
Id elem = q1.elements[ii];
1134-
if (ISRELDEP(elem) && GETRELDEP(pool, elem)->name == rd1->name)
1135-
{
1136-
printf("Reldep: %s\n", pool_dep2str(pool, elem));
1137-
}
1138-
}
1139-
printf("\nQ2: \n");
1140-
for (int ii = 0; ii < q2.count; ++ii)
1141-
{
1142-
Id elem = q2.elements[ii];
1143-
if (ISRELDEP(elem) && GETRELDEP(pool, elem)->name == rd1->name)
1144-
{
1145-
printf("Reldep: %s\n", pool_dep2str(pool, elem));
1146-
}
1147-
}
1148-
}
11491079

11501080
if (!deps_unequal)
11511081
{
1152-
printf("Deps equal, continue\n");
11531082
queue_push(&seen, rd1->name);
11541083
continue;
11551084
}
11561085

1157-
int aht_1, aht_2;
1158-
Id b1 = best_matching(pool, &q1, rd1->name, &aht_1);
1159-
Id b2 = best_matching(pool, &q2, rd1->name, &aht_2);
1086+
int aht_1, aht_2;
1087+
Id b1 = best_matching(pool, &q1, rd1->name, &aht_1);
1088+
Id b2 = best_matching(pool, &q2, rd1->name, &aht_2);
11601089

1161-
if (aht_1 != aht_2)
1162-
{
1163-
comparison_result += (aht_1 - aht_2) * 100;
1164-
}
1090+
// one of both is not solvable
1091+
// add random (high) id here
1092+
if (b1 == 0 || b2 == 0)
1093+
continue;
1094+
// comparison_result += (b1 - b2);
1095+
1096+
// if one has deps with track features, and the other does not, downweight
1097+
// the one with track features
1098+
if (aht_1 != aht_2)
1099+
comparison_result += (aht_1 - aht_2) * 100;
11651100

1166-
comparison_result += pool_evrcmp(pool, b2, b1, 0);
1101+
comparison_result += pool_evrcmp(pool, b2, b1, 0);
11671102
}
11681103
return comparison_result;
11691104
}
@@ -1181,9 +1116,20 @@ sort_by_best_dependencies(const void *ap, const void *bp, void *dp)
11811116
sb = pool->solvables + b;
11821117

11831118
int res = conda_compare_dependencies(pool, sa, sb);
1184-
printf("Solvable comparison: %s vs %s: %d", pool_solvable2str(pool, sa),
1185-
pool_solvable2str(pool, sb),
1186-
res);
1119+
if (res == 0)
1120+
{
1121+
// no differences, select later build
1122+
Repodata* ra = repo_last_repodata(sa->repo);
1123+
Repodata* rb = repo_last_repodata(sb->repo);
1124+
1125+
unsigned long long bta = repodata_lookup_num(ra, a, SOLVABLE_BUILDTIME, 0ull);
1126+
unsigned long long btb = repodata_lookup_num(rb, b, SOLVABLE_BUILDTIME, 0ull);
1127+
res = btb - bta;
1128+
}
1129+
1130+
POOL_DEBUG(SOLV_DEBUG_POLICY, "Selecting variant [%c] of (a) %s vs (b) %s (score: %d)\n",
1131+
(res < 0 ? 'a' : 'b'), pool_solvable2str(pool, sa), pool_solvable2str(pool, sb), res);
1132+
11871133
return res;
11881134
}
11891135

0 commit comments

Comments
 (0)