-
Notifications
You must be signed in to change notification settings - Fork 55
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
make rev() detect all parents of the given commits #1326
Conversation
I have also checked that Miri still works with this version of josh -- i.e., even though the filter used by Miri technically changed its meaning (since it now checks for "ancestors"), the extracted history is the same as before. The ancestors semantics is what we always wanted in Miri, and it is what I originally implemented in #961, which means it is also how Miri was originally josh-ified. Then when we switched to the official |
return Ok(Some(start)); | ||
} else { | ||
return Ok(None); | ||
for (&filter_tip, startfilter) in filters.iter() { |
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 iterates the filters in unspecified order, as HashMap does not have stable iteration order. This means if the parent-sets of the commits given in a rev
overlap, behavior would be non-deterministic...
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.
filters
is already a BTreeMap
for exactly that reason.
It's probably slower, but determinism is more important.
Looking at the usage we could change it to an ordered Vec
though 🤔
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.
Alternatively, maybe it should error if two of the parent-sets overlap?
f26332b
to
76f4488
Compare
The subtree_prefix test still works, but the
The last commit (0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb) is now an ancestor of the The test in fact exactly shows the duplication of history -- after the filter is applied, we have (before this PR):
Note there are two roots now, 0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb got duplicated and now exists as 0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb and 9f0db868b59a422c114df33bc6a8b2950f80490b. So is that truly the intended behavior of |
The reasoning of implementing However thinking about this again now it becomes clearer that this is not really the case: So thanks again for finding, reporting and analysing this brain twister bug :) I'll gladly take this one over and deal with test etc. |
Merged as #1329 |
The current implementation of
rev
does not work well when we have a history likeWithout this PR,
$parent
will be processed both with and without the filter: when josh traverses the left branch, it eventually hits$parent
without previously having seen$commit
and therefore now processes the ancestors of this commit without applying the filter. At least I think that's what happens in #1325.This implements what I sketched here: I need
rev($commit=FILTER)
to apply the given filter to all parents of commit no matter how they are referenced.So this changes
rev
semantics to instead detect when we reach any ancestor of the given$commit
, and then we start applying the filter. This has successfully extracted the rust-analyzer history in a way that I can then also do pushes.This is a draft because
:rev(55d9a533b309119c8acd13061581b43ae8840823+:prefix=src/tools/rust-analyzer)
to indicate "plus all parents" -- note the+
)(I also won't have more time to work on this for a bit, so if the approach seems acceptable than I wouldn't mind someone else taking over. :)