-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opam-0install-cudf: Add support for the avoid-version flag #37
Conversation
3767312
to
d5676b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some fly-by comments as I happened to be working on something related in ocaml-ci!
lib-cudf/opam_0install_cudf.ml
Outdated
let version_rev_compare context pkg1 pkg2 = | ||
let rev_cmp () = | ||
if context.prefer_oldest then | ||
Int.compare pkg1.Cudf.version pkg2.Cudf.version | ||
else | ||
Int.compare pkg2.Cudf.version pkg1.Cudf.version | ||
in | ||
if context.handle_avoid_version then | ||
match tagged_with_avoid_version pkg1, tagged_with_avoid_version pkg2 with | ||
| true, true | false, false -> rev_cmp () | ||
| true, false -> 1 | ||
| false, true -> -1 | ||
else | ||
rev_cmp () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function may be hot enough for it to be worth unrolling all four versions and selecting having:
let version_rev_compare context = if context.handle_avoid_version && context.prefer_oldest then version_rev_compare_avoid_oldest else (* ... *)
but it's certainly worth removing the auxiliary function:
let version_rev_compare context pkg1 pkg2 = | |
let rev_cmp () = | |
if context.prefer_oldest then | |
Int.compare pkg1.Cudf.version pkg2.Cudf.version | |
else | |
Int.compare pkg2.Cudf.version pkg1.Cudf.version | |
in | |
if context.handle_avoid_version then | |
match tagged_with_avoid_version pkg1, tagged_with_avoid_version pkg2 with | |
| true, true | false, false -> rev_cmp () | |
| true, false -> 1 | |
| false, true -> -1 | |
else | |
rev_cmp () | |
let version_rev_compare context = pkg1 pkg2 = | |
let avoid_version_pkg1 = context.handle_avoid_version && tagged_with_avoid_version pkg1 in | |
let avoid_version_pkg2 = context.handle_avoid_version && tagged_with_avoid_version pkg2 in | |
if avoid_version_pkg1 <> avoid_version_pkg2 then | |
if avoid_version_pkg1 then 1 else -1 | |
else if context.prefer_oldest then | |
Int.compare pkg1.Cudf.version pkg2.Cudf.version | |
else | |
Int.compare pkg2.Cudf.version pkg1.Cudf.version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in ea571ba, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i improved it further, the commit linked above is outdated
lib-cudf/opam_0install_cudf.mli
Outdated
@@ -6,16 +6,23 @@ type diagnostics | |||
|
|||
val create : | |||
?prefer_oldest:bool -> | |||
?handle_avoid_version:bool -> (* TODO: Make it true by default on the next major breaking release *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to wait for this? Or it simply that opam itself can opt-in to enabling it immediately? It feels like a bug that it was ignoring it before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the parameter entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've put it back but made it true by default
738ed61
to
00b7d4f
Compare
ea571ba
to
e72a6f6
Compare
e72a6f6
to
884aafa
Compare
884aafa
to
6a02b51
Compare
6a02b51
to
76ffd4a
Compare
Moved to ocaml-opam/opam-0install-cudf#2 |
Take 2. Superseds #35
For some reason I hadn’t thought of this very simple solution in #35...