This is an archive of the discontinued Mercurial Phabricator instance.

dirstate-v2: Make more APIs fallible, returning Result
ClosedPublic

Authored by SimonSapin on May 19 2021, 12:37 PM.

Details

Summary

When parsing becomes lazy, parse error will potentially happen in more places.
This propagates such errors to callers.

Diff Detail

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

Event Timeline

SimonSapin created this revision.May 19 2021, 12:37 PM
baymax updated this revision to Diff 28173.May 21 2021, 4:37 AM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare added inline comments.
rust/hg-core/src/dirstate.rs
80–85

Getting to 5 lines-high type declaration without Futures is a feat!

rust/hg-core/src/dirstate_tree/dirstate_map.rs
518

Isn't there such an iterator in itertools already? Since we depend on it anyway.

SimonSapin added inline comments.May 21 2021, 8:06 AM
rust/hg-core/src/dirstate.rs
80–85

Oh I hadn’t checked what rustfmt had done to this. Do you think it’d be better with separate type definitions for iterated items, in order to keep each definition on one line?

rust/hg-core/src/dirstate_tree/dirstate_map.rs
518

I don’t find exactly this. https://docs.rs/itertools/0.10.0/itertools/trait.Itertools.html#method.filter_map_ok is close but requires the callback to be infallible, whereas we want to potentially emit new errors while filtering/mapping.

baymax updated this revision to Diff 28272.May 30 2021, 3:27 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare accepted this revision.May 31 2021, 3:46 AM
Alphare added inline comments.
rust/hg-core/src/dirstate.rs
80–85

I don't think it matters too much as far as I'm concerned, but some people might argue the opposite. They can send a patch ;)

rust/hg-core/src/dirstate_tree/status.rs
121

I wonder if the compiler will optimize the two loops somehow. But we can take a look at this in the profiling phase, later.

This revision is now accepted and ready to land.May 31 2021, 3:46 AM