Skip to content

Really compute transitive dependencies in opam_mk_repo (Close: #976). #977

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

Merged
merged 4 commits into from
Nov 13, 2013
Merged

Really compute transitive dependencies in opam_mk_repo (Close: #976). #977

merged 4 commits into from
Nov 13, 2013

Conversation

Image for: Conversation
Copy link
Member

No description provided.

if OpamPackage.Set.mem nv set then
set
else
OpamPackage.Set.union
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's simpler to write:

OpamPackage.Set.(add nv (union (get_dependencies nv) set))
Copy link
Member

samoht commented Nov 6, 2013

Woops... Thanks for the fix! Can you just correct that minor remark ?

Copy link
Member

samoht commented Nov 7, 2013

After some thoughts I'm not totally convinced by your fix. I think it will be safer to simply add nv to the set returned by get_dependencies (not sure why you've added the if .. then .. else construct there: this works only if we are lucky with the order in which we traverse the already computed set).

Copy link
Member Author

If nv is already in the set, it means that it has already been visited, so there is no reason to go through it once again. That is the reason of the if then else.

Adding the element to the get_dependencies, change slightly the meaning of the function since it will return not only the deps but the deps and itself (but that may be fine).

Doing it without the if then else, is fine. BUT not good in term of complexity because the set keep expanding with each recursive call and even if you already have computed deps you will try again to get it again and again...

But this is just my 2 cents and my 2 min hack done done late at night, I may have some bugs here.

Copy link
Member

samoht commented Nov 7, 2013

If nv is already in the set, it means that it has already been visited, so there is no reason to go through it once again. That is the reason of the if then else.

Well not necessary; if nv is in the set it can also be a dependency of something we already have visited.

Copy link
Member Author

Oh god, you are right in fact. I was mislead but the fact that we have only one set.

We should visited and to_visit set, and the end condition is that to_visit set must be empty.

Copy link
Member Author

will fix that tonight, but the former algo was wrong anyway and the complexity argument stands.

Copy link
Member Author

I think this is fixed, please take another look.

samoht added a commit that referenced this pull request Nov 13, 2013
Really compute transitive dependencies in opam_mk_repo (Close: #976).
samoht merged commit 8d7dddd into ocaml:master Nov 13, 2013
Copy link
Member

samoht commented Nov 13, 2013

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants