( )⚙ D11398 rust: Add Repo::dirstate_map and use it in `rhg status`

This is an archive of the discontinued Mercurial Phabricator instance.

rust: Add Repo::dirstate_map and use it in `rhg status`
ClosedPublic

Authored by SimonSapin on Sep 10 2021, 11:11 AM.

Details

Summary

This moves low-level dirstate wrangling out of the status command and into
a more reusable location.

The open dirstate map is lazily initialized and kept on the Repo object,
for reuse by sub-sequent calls.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

SimonSapin created this revision.Sep 10 2021, 11:11 AM
Alphare accepted this revision.Sep 13 2021, 6:38 AM
Alphare added a subscriber: Alphare.

Cool ! That should speed up some operations, especially with more complex commands.

rust/hg-core/src/repo.rs
270

Should we set the parents to DirstateParents::NULL here?

311

I had no idea you could re-assign to a dropped variable, but I guess it makes sense.

This revision is now accepted and ready to land.Sep 13 2021, 6:38 AM
SimonSapin updated this revision to Diff 30208.Sep 13 2021, 6:41 AM
SimonSapin added inline comments.Sep 13 2021, 6:44 AM
rust/hg-core/src/repo.rs
270

Indeed! Done. (Though it’s not critical, it just saves the dirstate_parents getter from opening on trying to open the .hg/dirstate file again.)