RebuildNotedb: batch changes by project

If we batch changes by project before rebuilding them and writing them
to the notedb, we can use a single BatchRefUpdate for all of the
changes in a project, which reduces overhead for writing every change
to the notedb.

Additionally, within the code the rebuilds each change, I synchronized
on the BatchRefUpdate object because it is not thread safe. Since all
changes in a project will be using the same one, we can just
synchronize the function calls that modify that BatchRefUpdate.

Change-Id: I4af196fa720180b0846e9a6e7cc6d9083a75f695
Add function to set inserter for AbstractChangeUpdate

The ChangeRebuilder will need to set the inserter for every
AbstractChangeUpdate that it wants to construct and write to the
notedb, so we can use this method for that.

Change-Id: I8821cf9e588de2b4db094aafa44876c6322be101
Factor out writing of commit for notedb updates

For the sake of rebuilding the notedb, we would like to write all
commits for all AbstractChangeUpdates on a project to the object
database, before committing a single BatchRefUpdate to update all the
refs.  This refactoring makes that possible.

Change-Id: I864b2845b32426a55a3f62910ae09910bc25901e
Fix VersionedMetaData for multiple commits in one batch

I noticed that if you make a modification to the notes tree
(i.e. insert comments) and then make a modification to the commit at
the meta ref (i.e. insert approvals) within one BatchMetaDataUpdate,
then the notes tree update will be squashed by the second update. I
added tests to show this case and corrected this by using the tree
from the parent commit unless there are new contents in the DirCache
to be written.

Change-Id: I83f09e08f472c21dc4bc06f00c3706a18d170f9c
ChangeIT: Just use changeId instead of triplet

Change-Id: I3ca9f137ee92e65739ef1d51ef6bd8c17dc6d34b
Warn extension API users that underlying objects are read eagerly

Storing references to these APIs is risky because modifications via
the API instance may or may not be reflected in later getter calls,
depending on what part of the object was modified and how the
implementation works. Explicitly discourage this behavior, and change
all callers within Gerrit.

A later change may remove this recommendation after modifying all API
implementations, but that is an unknown amount of work, and there is
no harm in documenting the current behavior now.

Change-Id: I1921b619753b1d1cc60426704f68ff0318bf6fe5
GWT DevMode is dead; set up SuperDevMode

The codeserver runs separately and cannot easily be embedded in Gerrit
because it depends on an outdated version of Jetty. We may change this
behavior when GWT is updated.

Prerequisite is to download gwt-codeserver.jar and dependencies:

  buck build codeserver

Start CodeServer with new launch configuration:

  tools/eclipse/gerrit_gwt_codeserver.launch

And follow the instructions: [1].

[1] http://stackoverflow.com/a/18333050/116472

Inspired-By: Thomas Broyer <t.broyer@gmail.com>
Change-Id: Ieff7190db6bc151eae1274105ccf828eaa652027
Fix isMergedIntoVisibleRef check to handle prefix in RefMap

RefMap does not accept mixed prefixes, as this could cause a
key collision. Adding R_HEADS and R_TAGS to the same RefMap
will always fail.

Instead pull the refs into a List<Ref> and work from that.

Change-Id: I57a463cc462b97e3ed6ac76bc8d8129c88819b03