Writes out a fresh copy of the inventory that minimizes the
amount of inventory that need be downloaded when people pull from
the repository.

Specifically, it breaks up the inventory on the most recent tag.
This speeds up most commands when run remotely, both because a
smaller file needs to be transfered (only the most recent
inventory). It also gives a guarantee that all the patches prior
to a given tag are included in that tag, so less commutation and
history traversal is needed. This latter issue can become very
important in large repositories.

Similar to the ask function of the MonadReader class.
This allows actions in the RIO monad to get the current
repository.
FIXME: Don't export this. If we don't export this
it makes it harder for arbitrary IO actions to access
the repository and hence our code is easier to audit.

hunt upwards for the darcs repository
This keeps changing up one parent directory, testing at each
step if the current directory is a repository or not. $
The result is:
Nothing, if no repository found
Just (Left errorMessage), if bad repository found
Just (Right ()), if good repository found.
WARNING this changes the current directory for good if matchFn succeeds