On reconfiguration, re-enqueue items at the same position

Upon reconfiguration, we currently re-enqueue every item back
into its pipeline, in case a difference in the configuration would
change what should occur.  In the simple case, this is fine, but
if a dependent pipeline has a branching dependency structure due
to already failing jobs, we would erroneously re-order the changes
back into a linear arrangement.  The next pass through the pipeline
manager would move those items back to where they should be, but
in doing so, would reset their builds.

To correct this, after re-enqueueing a change, if the change that
was previously ahead of it in the pipeline was also successfully
re-enqueued, immediately move the change behind it (or if the
change ahead was "None" meaning it was its own head, move it behind
no change).  This should have the effect of putting changes back
where they were in relation to other failing changes.  If the change
ahead was not successfully re-enqueued, the current behavior of
simply putting it behind the nearest change in the queue is preserved.
If anything more complex happens, any errors will be corrected on the
next pass through the pipeline manager.

Change-Id: Ie3771d9bbbc1ca77425cf62751d8e5f70ba1f14c
4 files changed