dirstate: fix rebuild; add a test
If rebuild calls invalidate, it will just queue a (re)read of the dirstate
file, while what we really want is to empty the current state.
adding a
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding b
pushing to ../a
abort: could not lock repository ../a: Permission denied