( )⚙ D11517 dirstate: Remove the Rust abstraction DirstateMapMethods

This is an archive of the discontinued Mercurial Phabricator instance.

dirstate: Remove the Rust abstraction DirstateMapMethods
ClosedPublic

Authored by SimonSapin on Sep 29 2021, 10:56 AM.

Details

Summary

This Rust trait used to exist in order to allow the DirstateMap class exposed
to Python to be backed by either of two implementations: one similar to the
Python implementation based on a "flat" HashMap<HgPathBuf, DirstateEntry>,
and the newer one based on a tree of nodes matching the directory structure
of tracked files. A boxed trait object was used with dynamic dispatch.

With the flat implementation removed and only the tree one remaining, this
abstraction is not useful anymore and the concrete type can be stored directly.

It remains that the trait was implemented separately for DirstateMap<'_>
(which takes a lifetime parameter) and OwningDirstateMap (whose job is to
wrap the former and hide the lifetime parameter), with the latter impl only
forwarding calls.

This changeset also removes this forwarding. Instead, the methods formerly of
the DirstateMapMethods trait are now inherent methods implemented for
OwningDirstateMap (where they will actually be used) but in the module that
defines DirstateMap. This unusual setup gives access to the private fields
of DirstateMap from those methods.

Diff Detail

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

Event Timeline

SimonSapin created this revision.Sep 29 2021, 10:56 AM
Alphare accepted this revision.Sep 29 2021, 12:35 PM
Alphare added a subscriber: Alphare.
Alphare added inline comments.
rust/hg-core/src/dirstate_tree/owning.rs
47

Good catch!

This revision is now accepted and ready to land.Sep 29 2021, 12:35 PM
rust/hg-core/src/dirstate_tree/owning.rs