Skip to content

Commit 7ef80f4

Browse files
committed
fix check unequal deps function to work in all cases
1 parent f936737 commit 7ef80f4

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

src/policy.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -968,16 +968,29 @@ void intersect_selection(Pool* pool, Id dep, Queue* prev)
968968

969969
int check_deps_unequal(Pool* pool, Queue* q1, Queue* q2, Id name)
970970
{
971-
Id h1 = 0, h2 = 0;
972-
int i;
973-
971+
Id dep;
972+
int i, j;
973+
int found = 0;
974974
for (i = 0; i < q1->count; ++i)
975-
h1 ^= q1->elements[i];
976-
977-
for (i = 0; i < q2->count; ++i)
978-
h2 ^= q2->elements[i];
975+
{
976+
dep = q1->elements[i];
977+
if (ISRELDEP(dep) && GETRELDEP(pool, dep)->name == name)
978+
{
979+
for (j = 0; j < q2->count; ++j)
980+
{
981+
if (q2->elements[j] == dep)
982+
{
983+
found = 1;
984+
break;
985+
}
986+
}
987+
if (!found)
988+
return 1;
979989

980-
return h1 != h2;
990+
found = 0;
991+
}
992+
}
993+
return 0;
981994
}
982995

983996
Id best_matching(Pool* pool, Queue* q, Id name, int* all_have_trackfeatures)
@@ -1061,7 +1074,6 @@ int conda_compare_dependencies(Pool *pool, Solvable *s1, Solvable *s2)
10611074

10621075
// first make sure that deps are different between a & b
10631076
int deps_unequal = check_deps_unequal(pool, &q1, &q2, rd1->name);
1064-
10651077
if (!deps_unequal)
10661078
{
10671079
queue_push(&seen, rd1->name);
@@ -1076,7 +1088,6 @@ int conda_compare_dependencies(Pool *pool, Solvable *s1, Solvable *s2)
10761088
// ignoring this case for now
10771089
if (b1 == 0 || b2 == 0)
10781090
continue;
1079-
// comparison_result += (b1 - b2);
10801091

10811092
// if one has deps with track features, and the other does not,
10821093
// downweight the one with track features
@@ -1114,7 +1125,9 @@ sort_by_best_dependencies(const void *ap, const void *bp, void *dp)
11141125

11151126
unsigned long long bta = repodata_lookup_num(ra, a, SOLVABLE_BUILDTIME, 0ull);
11161127
unsigned long long btb = repodata_lookup_num(rb, b, SOLVABLE_BUILDTIME, 0ull);
1117-
res = btb - bta;
1128+
1129+
res = (btb > bta) ? 1 : -1;
1130+
POOL_DEBUG(SOLV_DEBUG_POLICY, "Fallback to timestamp comparison: %llu vs %llu: [%d]\n", bta, btb, res);
11181131
}
11191132

11201133
POOL_DEBUG(SOLV_DEBUG_POLICY, "Selecting variant [%c] of (a) %s vs (b) %s (score: %d)\n",

0 commit comments

Comments
 (0)