Fix up remote repo handling.
Simplify how CI tracking saves state, and add some helpers.

This changes the state tracking metadata to not explicitly have
timestamp and committer information embedded in the states, as those
can be inferred from the commit history.

It also allows for a state to point to multiple previous states, which
is a requirement for some of our state transitions.  Future commits
will add more metadata to support allowing one state to transition to
many states, and to know when all the required transitions for a one
-> many transision has happened.

fetch_ci_tracking has been split into fetch_ci_tracking and
push_ci_tracking.  The former is mainly responsible for cloning the CI
tracking repository if it does not exist, and calling push_ci_tracking
if it does.

push_ci_tracking fetches changes from upstream and tries to rebase any
local state changes on top of the fetched changes and push the
changes (if any) back upstream.  If the rebase fails, or the rebased
changes cannot be pushed back upstream due to merge conflicts, it will throw
away local changes which will have to be regenerated.

Linking an old state to a new state has been formalized with
ci_link_state and its helper functions.  ci_link_state has the
responsibility of never generating an invalid state transition graph,
so any changes to it must preserve that property.

ci_next_states has been tidied up.

ci_get_current_state_paths has been renamed to ci_get_current states,
and updated to take the possibility of having multiple previous states
for a state into account.

Added helpers to mark tracked pull requests as merged or closed based
on the state of their respective Github pull requests. See
ci_close_stale_pull_requests for more information.

Added a helper to detect when the commits involved in a pull request
have changed and reset the state graph for that pull request.

Modified ci_import_new_pull_requests to run the close and reset helpers.

Modified fetch_all to run fetch_ci_tracking and ci_import_new_pull_requests.
Merge pull request #1672 from VictorLowther/pull-req-more-ci-stuff

Expose rudimentary CI infrastructure