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.
#header#
<title>Mercurial Error</title>
</head>
<body>
<h2>Mercurial Error</h2>
<p>
An error occured while processing your request:
</p>
<p>
#error|escape#
</p>
#footer#