This is an archive of the discontinued Mercurial Phabricator instance.

hg-core: add `Revlog.get_node_rev`

Authored by acezar on Sep 11 2020, 3:53 AM.



Find the revision of a node given its full hash.

Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

acezar created this revision.Sep 11 2020, 3:53 AM
Alphare requested changes to this revision.
Alphare added inline comments.

I know Clippy will complain about the lack of is_empty method when you have a len method, if you want to add it quickly.


Wouldn't it make more sense to start from the end as we're more likely to be looking for recent nodes?

Also, it's not clear by looking at this that this bruteforce method is not the one we'll use in the future, using @gracinet's nodemap. I think a small comment would be enough.

This revision now requires changes to proceed.Sep 17 2020, 6:11 AM
acezar added inline comments.Sep 18 2020, 8:46 AM

I've seen the clippy warning, but did not added it because it wasn't needed and since it's not enforced by an interface, I was not sure about what to do about it. Maybe having 0 warning on easy things should be a goal.


Like you said we're more likely to be looking for recent nodes thus searching from the start when the revolg is huge is probably not the way to go.

acezar updated this revision to Diff 22723.Sep 18 2020, 10:49 AM
acezar marked 2 inline comments as done.Sep 18 2020, 10:52 AM
acezar added inline comments.

It has been added in another commit. I moved the code here

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.