Delete a change from the index when it is not in the DB

If for some reason the secondary index is out of date, i.e. the  change
was deleted from the database but wasn't deleted from the secondary
index, it was impossible to re-index (remove) that change.

Add logic to automatically remove the change from the secondary index
if this change is requested through the Change REST API endpoint and
doesn't exist in the database.

If a user click on search result from a stale change, he will a get a
404 page and the change will be removed from the index.

To fix the problem without opening the change page, run a command like:
curl --user <user name>  -X POST http://<host>:<port>/a/changes/<change id>/index

Issue: 2996
Change-Id: I1db5373e31585e99c5f45e05274d86d69b4f24e6
Remove uneeded dependency in ChangesCollection

Change I1db5373e31585e99c5f45e05274d86d69b4f24e6 added an unneeded
dependency in ChangesCollection.

Change-Id: I2f8609416518495624eda9e08309a6e14863fbe8
Merge branch 'stable-2.9' into stable-2.10

* stable-2.9:
  Remove uneeded dependency in ChangesCollection
  Delete a change from the index when it is not in the DB

Change-Id: Ifed2fc5073071e9d4f457aa02b73caa2b6173599
Merge branch 'stable-2.10'

* stable-2.10:
  Remove uneeded dependency in ChangesCollection
  Delete a change from the index when it is not in the DB

Change-Id: I02a4773dd581c29704a7cc45c5225258d657f836
Remove unused import in Daemon

Change-Id: If7d83e89a38a3ad397e22053eb3a48c718735379
Simplify ChangeIndex by removing delete(ChangeData)

Since indexing is generally done after any modification operations,
using a deleted ChangeData when indexing a deleted change is just
asking for trouble; most ChangeData methods (reasonably) assume that
the change exists. Instead, just use the form of the method that
passes in the ID.

Change the method that takes an integer ID to take a Change.Id object.
In almost all cases we already have one of these handy, and this is
more consistent with public interfaces elsewhere in Gerrit.

A fortunate side effect is that async deletes should happen slightly
faster, since we no longer need to open a DB connection and produce a
ChangeData in the delete codepath.

Change-Id: I353522b52188de11353ca26a7ba90a2ca462e404
Enable streaming large files put to an edit

If the browser/user-agent sends a Content-Length header in the
request, JGit can stream the payload into the compressed object
format without holding the entire payload inside the server's
heap. This can reduce memory pressure when the user edits a
large XML file.

Push the RawInput down into the ChangeEditModifier, giving it access
to the expected length. If the length is defined (>= 0), JGit can
stream the payload from the input.  If the user agent failed to
supply a length, the payload must be buffered to compute it.

Cleanup the ChangeEditModifier management of the tree by doing blob
insertion before the tree is updated. This allows passing in only
the ObjectId, which is cleaner for the Git style code.

When restoring an entry with RESTORE_ENTRY, reset the file mode to
the original mode. This preserves the execute bit or symlink mode,
instead of resetting them to regular file.

When editing an entry, try to keep the existing mode instead of
forcing to a regular file. This allows editing an executable script
file and keeping the file executable.

Change-Id: I8f45fd4a4a45cef266d994c2457d3e100231c312
Merge "Enable streaming large files put to an edit"
Fix a typo in Documentation/prolog-cookbook.txt

Change-Id: I54e6fbfd36ede07f6a83994451c068b90ee700cf