dirstate: set identity whenever we read the dirstate's v2 docket
The docket can be loaded outside of a full read (for exemple when
pre-fetching parents), so the current code would read/set the identity
after loading the data, opening a race condition:
A0: first process docket is read
B0: other process appends new data to the dirstate (and changes the docket)
A1: first process sets the identity (based on pre-B content, but with post-B identity)
A1: first process loads the dirstatemap from the data file
A1: first process does not detect the race and overwrites the update from B.
dirstate: factor the identity setting code in the dirstate map
We need it in more locations, so let us start factoring thing out first
to make sure the same code is called everywhere.
This bears some similarity with
85746485a4dd on default, but at a smaller
scope and for a different purpose.
dirstate: simplify the dirstate's read race testing
Now that most code behaves properly, we can simplify the expected matching.
dirstate: deal with read-race for pure rust code path (rhg)
If we cannot read the dirstate data, this is probably because a writing process
wrote it under our feet. So refresh the docket and try again a handful of time.
dirstate: deal with read-race for python code using rust object
If we cannot read the dirstate data, this is probably because a writing process
wrote it under our feet. So refresh the docket and try again a handful of time.
dirstate: deal with read-race for pure python code
If we cannot read the dirstate data, this is probably because a writing process
wrote it under our feet. So refresh the docket and try again a handful of time.
dirstate: abstract the reading of the data file in v2 in a method
We will need more changes to avoid some race conditions during read,
so we first isolate the simple logic before making it more complicated.
dirstate: add append/new-file variants in the dirstate's read race tests
This covers more ground and finds more bugs.
At that point I gave up on making things as `known-bad-output` /
`missing-correct-output` as this gets too messy.