Backport dose patch for upgrade bug

Also cleans up patching process: I now maintain a dose git branch to generate
a cleaner stream of patches.

This allows to rebuild the branch from dose 3.1.2 git using
`git am <opamsrc>/src_ext/patches/dose/*.patch`

Thanks @abate and @rdicosmo. Closes #1104