This is a major refactoring/rewrite of the prepare-upload code. So much
changed that it didn't seem worth breaking it down. It's probably easier
to review afresh.
Functionally, what has changed is that we now fetch from the remote
using its default configured refspecs first, assuming that this will
update the remote tracking branch following normal conventions. Then we
can determine if the remote branch already contains our rich history or
not. We then only push if it does not.
In the code, this involved considerable refactoring. There is now a
Parameters namedtuple that carries the various facts around, and the
determination of these facts are moved into a classmethod constructor
method within that class. Various common steps betweent the "args" and
"mangle" operations are broken out.
snapcraft regressed in that it now rejects apt signing keys that have
subkeys. This is reported upstream, but the easiest thing to do for now
is work around by not generating them. This diverges from gpg's default,
but subkeys are not needed for apt signing keys anyway.
Passing an empty cache dir to the launchpad download method pollutes the
working directory, causing the subsequent dpkg-buildpackage to fail.
Sidestep this bug and just use the tested code path instead.