Plug memory leak.

pg_rewind only runs once so minor leaks don't generally matter. But this
runs once for file, so it's probably worth plugging.
Flush output after printing the filemap.

Makes the log nicer to read when stdout and stderr outputs are not mixed
up so badly.
Fix rewinding over DROP DATABSE.

The PG_VERSION file was ignored in source and destination, and hence not
deleted. Removing the directory then failed, because the PG_VERSION file
was still in it.

Also add a regression test.