~racb/git-ubuntu:reimport-service

Last commit made on 2020-05-27
Get this branch:
git clone -b reimport-service 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:
reimport-service
Repository:
lp:~racb/git-ubuntu

Recent commits

546a7fb... by Robie Basak

Convert import request structure to namedtuple

Converting the tuple of (str, bool) to an explicit namedtuple makes the
code more readable.

6c90bd7... by Robie Basak

Add --lp-user and --lp-owner to importer service

If we can specify the Launchpad authentication user and target team for
imports, then we can test the importer service outside production.

This just passes the specified parameters through to the underlying "git
ubuntu import" call.

674bf39... by Robie Basak

Add reimport support to the importer service

This allows reimports to be requested by injecting a reimport request
directly into the state database. There is deliberately no API for
requesting a reimport as this will never be done during normal
operation, and a sysadmin can use the sqlite3 CLI nearly as easily as a
dedicated CLI just for this operation, so I've opted not to implement a
dedicated CLI.

Previously "requests" were just a list of source package names as
strings, so weren't really explictly labelled as such. Now that we have
to actually track these, I've used a tuple(str, bool) as the simplest
way of identifying regular vs. reimport requests. This structure is now
used extensively in the importer service handling code and I've used the
general term "request" to refer to it.

Changes to importer_service_test.py are covered by a complete test suite
in importer_service_test.py, continuing 100% test coverage with
additional tests for the reimport cases against all changes. Coverage
for mailer.py is similarly maintained for these changes.

scriptutils.py and import-source-packages.py are however not currently
tested, and adding tests for these is therefore not currently practical.

In mitigation:

 * The changes are small and can be verified by hand without too much
   difficulty. All of the changes are in docstrings, comments and
   variable renames to match the new "request" semantics, and there are
   no algorithmic changes: everything is just "passed through".

 * Since the importer itself runs idempotently and no change to it is
   required here, we can have confidence that even if these changes are
   buggy, the imported repositories won't really be affected.

 * Worst case scenarios: reimports happen when they shouldn't; regular
   imports happen when they should have been reimports; and similar. All
   of these can be detected by the "logging" performed via importer
   notes which report which version and at what time an an individual
   import took place.

810d0a4... by Robie Basak

Add to kernel blacklist

d2c4d91... by Andreas Hasenack

Import squashfs-tools-ng

e990e66... by Andreas Hasenack

Add sbuild-launchpad-chroot, requested by smoser on IRC

0376fea... by Robie Basak

Fix docstring

This docstring was incorrect. The function uses a repo fixture, not a
repo_factory fixture, so update the docstring to match.

046bb42... by Robie Basak

Fix rich history preservation unescaped patch bug

It turns out that "git format-patch --stdout ... | git am" does not
correctly round-trip in every case. If a commit message contains
something that looks like a patch, "git am" incorrectly tries to apply
it.

Instead, we can note the commits that need to be rebased at export time
with "git rev-list --reverse", and apply them at import time with "git
cherry-pick". This keeps everything "inside git" instead of
round-tripping through an mbox, working around the problem.

This does mean that the repository to which the import happens must have
the commits available, which commonly would mean that the export
destination repository must be the same as the import source repository.
As it happens, this is always the case for us anyway during a
--reimport, so this will work just fine.

d4d29bc... by Robie Basak

Test rich history preservation unescaped patch bug

If a rich history commit _message_ contains something that looks like a
patch, the current implementation will attempt to apply it even though
it shouldn't. This test checks this case, but fails for now as the bug
exists, so we mark it xfail to verify that the test works.

ba0f853... by Robie Basak

Use the same repo fixture in round trip test

We will shortly be changing rich history preservation to use
cherry-picks to fix a bug. This will require the same repository to be
used for rich history import as the commits being imported will need to
be present in the repository still. Tests will therefore need to use the
same repository for import as they did for export.

This does rely on the test cleanly and correctly removing all previous
relevant tags in order to properly test the import, making it a little
more error prone, but we have no choice given the new requirement.

Since this was previously the only use for our repo_factory fixture, we
can drop it from the code base, together with its documentation. If it
is needed again later, we can always pull it out of VCS again.