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.
*** failed to import extension badext: bit bucket overflowextension 'hgext.gpg' overrides commands: sigs sigcheck signhg help [COMMAND]show help for a command, extension, or list of commands