~racb/git-ubuntu:fix-applied-branch-updates-wip

Last commit made on 2017-11-24
Get this branch:
git clone -b fix-applied-branch-updates-wip https://git.launchpad.net/~racb/git-ubuntu
Only Robie Basak can upload to this branch. If you are Robie Basak please log in for upload directions.

Branch merges

Branch information

Name:
fix-applied-branch-updates-wip
Repository:
lp:~racb/git-ubuntu

Recent commits

e7002be... by Robie Basak

Add quilt env handling tests

f7a28df... by Robie Basak

Log applied import error traceback on exception

As we're swallowing the error in a catch-all exception handler here,
it's helpful if we at least log the full exception and traceback.

I've also filed LP 1734349 to see if this could be improved (I'm not
sure).

71d7004... by Robie Basak

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.

4a619a1... by Robie Basak

Rename quilt_env_from_commit_hash

This implementation is actually more generic. It will accept anything
that is a treeish hex string, so relabel it and its callers
appropriately.

8a284e5... by Robie Basak

GitUbuntuRepository.quilt_env to take treeish

Take a treeish instead of a commit hash hex string and provide a wrapper
for old callers.

This is one step towards a move to using pure objects in most
parameters.

It's needed now so that the importer can also use quilt_env providing
only a treeish object. I could also have changed the method definition
to something intermediary, but as this is the eventual goal anyway,
might as well do it now.

a85e467... by Robie Basak

Factor out quilt env determination

cce925f... by Robie Basak

Find a tag for the current (not previous) import

It looks like this was an accidental regression in commit 0f3c9430.
'version' refers to the last set version in the for loop above, instead
of 'spi.version' which is the current package being imported.

'version' thus referred to the previously found tag, which of course
always exists. The code therefore assumed that the current version
doesn't need importing since the tag already exists, which is wrong.

Unfortunately this area of code doesn't have effective test coverage yet
and it isn't practical to add it here yet. My importer testing spike
will separately have to refactor and cover this. In the meantime a fix
without a test will have to do.

7e79017... by Robie Basak

Add .git escaping

If a source package unpacks to contain any files or directories named
'.git', it cannot be represented in a git repository as-is because the
name '.git' is reserved by git and git will not permit it to be an entry
in a git tree object.

Instead we losslessly escape these names by prepending a '.' recursively.

See discussion thread at
http://lists.alioth.debian.org/pipermail/vcs-pkg-discuss/2017-May/000976.html
(continuing into June).

LP: #1730778

54c9b42... by Robie Basak

Add .git escaping functions

ba12ad6... by Robie Basak

GitUbuntuRepository instantiation without lp_user

Instead of raising an exception immediately if lp_user cannot be
determined at instantiation time of GitUbuntuRepository, proceed with
_lp_user set to None.

The associated lp_user attribute getter will raise a RuntimeError if
_lp_user isn't set.

Other methods that use lp_user will check _lp_user first and raise a
more specific RuntimeError if _lp_user isn't set.

We can have confidence that this doesn't introduce a regression since
there should not be any code path which could proceed before without
successfully instantiating a GitUbuntuRepository. All this change does
is defer that exception (that must not have been happening in successful
use cases previously).

This allows for easier testability since we can now instantiate a
GitUbuntuRepository in tests without having to make sure that lp_user is
set first.