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.