gitubuntu: handle finding Ubuntu merge base with new importer layout
`git ubuntu merge` relies on the old importer algorithm setting a
publishing parent around, so we can find the common ancestor between
new/debian and old/ubuntu, via `git merge-base`.
This works even for cases where the branch pointers are forcibly moved,
as long as old/debian is an ancestor of new/debian. But when old/ubuntu
was based on an NMU or security update, there is no guarantee that
new/debian will have that base in its history.
Add a helper method to find the Ubuntu merge point, which will try and
verify that the merge-base found by Git has the correct version. If it
does not, it will fall back to just using the import tag for that
version. The first case corresponds to imports with the old algorithm
and the second to imports with the new algorithm.
This fails hard in the dictionary comprehension over timestamps since it
expects tuples of items instead of a list of keys. Use items() to
correctly provide the former.
import_patches_applied_tree: use correct quilt env
When quilt runs, we must use GitUbuntuRepository:quilt_env in order to
make sure that QUILT_* environment variables are set correctly.
Otherwise we rely on the importer runner having the correct quilt
environment set, which may not be the case.
Also see LP 1734137: separately we need to ensure that any /etc/quiltrc
or ~/.quiltrc is ignored correctly, but I'm treating that as a separate
bug as it needs a more significant refactor to wrap all quilt calls. We
should fix that bug before declaring hash stability, but it isn't as
important as this fix as that one is less likely to be a problem in
practice on our production importer.