Apparently it's not sufficient to modify a file to force the dirstate write-out, so the append code path was untested.
By removing a file instead of changing we're forcing append to happen.
We also change the dirstate writing code to do the same thing python does, to avoid bugs related to ZFS.