Author: Ben Franksen <email@example.com>
Date: Fri Sep 29 22:09:08 CEST 2017
* refactored convert darcs-2 command
There is no need to merge anything when converting, we can just add the
patches to the new repo, committing our changes every 100 patches like we
To get the types right was a challenge. I added checkRepoIsNoRebase to
Darcs.Repository.Job so as not to pollute the command implementation
host of obscure singleton types. Using foldFL_M requires two separate
newtype wrappers (W2 and W3) because the procedures we want to fold
simultaneously change two and three witnesses, respectively, and not just
the last one. It may be possible to encapsulate this somehow, but I leave
that to future refactorings. In spite of all that effort, we still need to
coerce the repo parameter in two places, which I extensively
to work around the types of finalizeRepositoryChanges and
revertRepositoryChanges (which are not precise enough) and another one to
work around the type of withRepoLock (which is too restrictive).
> noteIO "Cannot convert repo with rebase in progress." $
This is a bit misleading: if checkRepoIsNoRebase fails, something
must have gone seriously wrong, given we're checking the repository
we only just created. The "is a rebase in progress" check on the
source (V1) repo will be handled by V1Job.
It bugged me that we need this run-time check at all, just to make the
types fit. This is stupid.
So I went ahead and fixed the underlying problem, namely that
createRepository does not return a properly typed Repository. With that
change, and a few additional tools we can avoid withRepoLock and work
directly with the returned Repository.
The attached bundle contains the new patch, see its long comment for