Add a helper to sort ChangeDatas in RevWalk order

To do this, we have to define the mapping of change -> commit. In the
default case, we just pick the SHA-1 of the latest patch set. In a
more complex case, like listing related changes, we might be
interested in only a subset of patch sets, in which case we pick the
SHA-1 of the latest patch set in that subset.

Once we collect the mapping of change to commit, we can mark each
commit interesting, and do a simple RevWalk until we've seen every
interesting commit. This produces the order of changes within a single
project.

We also have to deal with multiple projects, for example if we want to
sort all changes across all projects matching a particular topic. To
do this, we keep groups by project together, and sort each group based
on the name of the project. This is more stable than alternatives
involving commit or change update time, since those are more likely to
change while a user is navigating among a list of changes in the
project.

Change-Id: I9a1fc7dbf308d1e4bde4d0ff1acf10b8aacb9b0f
3 files changed