This is an archive of the discontinued Mercurial Phabricator instance.

state: import the file to write state files from evolve extension
ClosedPublic

Authored by pulkit on Mar 3 2018, 2:19 PM.

Details

Summary

The current way of writing state files is very obscure with each state file
having it's own format to store state files. There is no centralized way to
write state files in a good format. Moreover the current state files are not
extensible, you cannot add more data to store in state files in reliable ways.

To solve the problem, I wrote my own serialization and deserialization format,
looked into existing formats like Protobuf, MessagePack, JSON but CBOR looks
very promising and is suggested by people in the community.

The current interface to store state files is to directly write data in files
when things abort. Using the class imported by this commit, we can create
objects which has a dict like interface and can store data on the object and
store it on the file when things abort.

The evolve extension is using the state file for evolve, grab commands and
using it for resolution of orphaness, phase-divergence and content-divergence.

The file is moved from changeset e4ac2e2c2086f977afa35e23a62f849e9305a225 of the
evolve extension which is also tagged as 7.3.0.
The following changes are made to the file while moving to core:

  • import util from current directory as this file in mercurial/ now
  • make cmdstate class extend object
  • removed mutable default value for opts in cmdstate.init
  • some doc changes to replace out of core things with in-core ones

evolve extension can be found at https://bitbucket.org/marmoute/mutable-history

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

pulkit created this revision.Mar 3 2018, 2:19 PM

This patch moves the file which is used to write state files easily in a good way using the cbor format.

Is "moves the file" referring to "import from the evolve extension"? It would also be good to be more concrete about what "easily in a good way" means. I get the feeling that there's a not-so-good way you have in mind that you want to prevent.

mercurial/state.py
62

drop "evolve" here and a few other places

indygreg requested changes to this revision.Mar 26 2018, 11:44 AM
indygreg added a subscriber: indygreg.

Pulkit apparently has changes for this series pending. Marking accordingly.

This revision now requires changes to proceed.Mar 26 2018, 11:44 AM
pulkit edited the summary of this revision. (Show Details)Mar 26 2018, 1:08 PM
pulkit updated this revision to Diff 7297.
pulkit marked an inline comment as done.Mar 26 2018, 1:15 PM
yuja added a subscriber: yuja.Mar 27 2018, 9:16 AM
yuja added inline comments.
mercurial/state.py
56

Nit: this seems too clever. I wouldn't expect if state issues a system call.

indygreg requested changes to this revision.Mar 28 2018, 2:22 PM
indygreg added inline comments.
mercurial/state.py
56

I agree. Let's not implement __nonzero__.

80

We probably want canonical=True here so behavior is deterministic. All that does in reality is sort dicts and sets. I doubt we have any data structures large enough for this to be a problem.

This revision now requires changes to proceed.Mar 28 2018, 2:22 PM

I was unable to followup on this. Let's leave this series here for the freeze and I will send new versions once freeze ends.

@martinvonz @yuja I am trying to get this series reviewed in pieces. This one and it's child D3572 is ready for review.

martinvonz added inline comments.May 17 2018, 12:48 PM
mercurial/state.py
80

Looks like you missed this. (If you didn't and you simply disagree, please explain why you disagree.)

pulkit added inline comments.May 17 2018, 2:22 PM
mercurial/state.py
80

I just simply missed it.

martinvonz accepted this revision.May 21 2018, 11:59 AM
This revision was automatically updated to reflect the committed changes.