( )⚙ D759 dirstate: move parents source of truth to dirstatemap

This is an archive of the discontinued Mercurial Phabricator instance.

dirstate: move parents source of truth to dirstatemap
ClosedPublic

Authored by durham on Sep 20 2017, 8:03 PM.

Details

Summary

As part of moving dirstate storage to its own class, let's move the source of
truth for the dirstate parents to dirstatemap. This requires that dirstate._pl
no longer be a cache, and that all sets go through dirstatemap.setparents.

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

durham created this revision.Sep 20 2017, 8:03 PM
indygreg requested changes to this revision.Sep 24 2017, 11:33 AM
indygreg added a subscriber: indygreg.

The logic here isn't readable enough that IMO we should fix it in flight.

mercurial/dirstate.py
1401–1402

This code doesn't read very cleanly.

The only cases where self._parents won't be set here are if the file exists but is empty or the file doesn't exist. I'd rather make that logic explicit and assert self._parents here.

Note that if the code were changed so an empty string represented both missing and empty files, the resulting code would be pretty clear via a switch statement against the content length.

This revision now requires changes to proceed.Sep 24 2017, 11:33 AM
durham updated this revision to Diff 2083.Sep 26 2017, 6:59 AM
durham marked an inline comment as done.Sep 26 2017, 7:00 AM
indygreg accepted this revision.Sep 29 2017, 2:05 PM
This revision is now accepted and ready to land.Sep 29 2017, 2:05 PM
This revision was automatically updated to reflect the committed changes.
mbolin added a subscriber: mbolin.Oct 7 2017, 8:09 PM
mbolin added inline comments.
mercurial/dirstate.py
320

Can/should parents(), p1(), and p2() here all be updated to go through map.parents()? We should be moving in the direction of removing _pl, no?