I'm getting reports of wrongly clean hg status, that get fixed by
running hg debugrebuilddirstate, which I suspect is the issue
below. And if it's not, it still seems good to fix.
hg commit works by adding new version of files from the working copy
into the store, then later lstat'ing the files in the working copy to
mark them as clean in the dirstate. This is racy, since the files can
be modified in the meantime.
Reduce the race by doing the lstat immediately after adding new file
versions into the store, and guarantee that the file size recorded in
the dirstate is correct (i.e. is the file size from the store).