Update replication plugin to latest revision

- Avoid throwing exception due to deleted change

Change-Id: Ic053278a6145acc4f10b430d08a4c77c7c9c96f2
Avoid CodeReviewCommit.error() whenever possible

The instances returned by this static factory method are severely
limited, in that they are not tied to actual commit objects. In most
cases, we can tie them to commit objects, so do that whenever
possible. Limit the statuses that we can pass to this method by
making it private, and creating separate factories only for those
statuses where there is really no commit.

Change-Id: I0cb392f4f7f5134d4a7487a2a7bb7ac9d770f334
Pass ChangeControl into CodeReviewCommit error instances

Within MergeOp these are keyed by Change.Id, but some error handling
code only receives the CodeReviewCommit and not the ID. That code is
reasonable in assuming there is a change/notes/control available, so
ensure this is the case when creating error instances.

Bug: issue 2911
Change-Id: If65398652f0e5b1a2b10a2fadc9a3b74bce7d556
Fix using HTTP methods other than GET from plugins

Commit 3bde74c2797 introduced a bug in the REST API. Methods other
than GET could not be used anymore  from plugins. For example it was not
possible anymore to delete projects with the delete-plugin using DELETE.

Bug: issue 2949
Change-Id: If90247ec4e0dad03b02d0a9e21202455fece90a7
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
(cherry picked from commit 3d227bbadfa234bcac7400cf41030423bf183ff3)
Refactor auto close change filtering in ReceiveCommits

Clarify when the autoCloseChanges() runs by moving the branch type
selection inside of the isHead || isConfig filter. This makes it a
bit more obvious when Gerrit runs a log and tries to close changes.

Change-Id: Ib62a2aedea98b2445dd4831d9b730609020503f3
Simplify parseBody call when looking at changes to close

Every commit is processed through parseBody(), yet the call is in two
locations within the traversal loop.  Clarify the body always gets
parsed and loaded by hoisting it to the top of the loop.

Simplify the loop variable by switching to a for(;;) style syntax,
which scopes the RevCommit variable to only the loop body.

Change-Id: I608f0e3f162ab52f4c24e156e09fadbf40f25d4b
Cache reused values in autoCloseChanges

The tip commit and branch key are passed into the submodule update
helper. Hold them in varibles for reuse, to reduce redundant code.

It is not necessary to reset the RevWalk. The submodule updater is
only using the revision pool to parse commits. It doesn't perform a
traversal, so the reset is merely wasting CPU cycles here.

Change-Id: Id6545033291539b862291eb88d6e8e85a24cb34c
Support annotated tags in push acceptance tests

Change-Id: I54b3425485e6a410783575acc05a7bedd5533ba4
Fix IncludingGroupMembership.containsAnyOf infinite loop

This class is using a map to store the memberOf and can be accessed
by multiple threads concurrently. The map was not synchronized which was
causing an infinite loop under very specific sequence of events. Here is
a snippet of the thread dump when that problem happened:

"SSH gerrit review ..." prio=1 RUNNABLE
java.util.HashMap.getEntry(HashMap.java:446)
java.util.HashMap.get(HashMap.java:405)
com.google.gerrit.server.account.IncludingGroupMembership.containsAnyOf(IncludingGroupMembership.java:77)
com.google.gerrit.server.account.UniversalGroupBackend$UniversalGroupMembership.containsAnyOf(UniversalGroupBackend.java:152)
com.google.gerrit.server.account.IncludingGroupMembership.search(IncludingGroupMembership.java:115)
com.google.gerrit.server.account.IncludingGroupMembership.containsAnyOf(IncludingGroupMembership.java:93)
com.google.gerrit.server.account.IncludingGroupMembership.contains(IncludingGroupMembership.java:69)
com.google.gerrit.server.account.UniversalGroupBackend$UniversalGroupMembership.contains(UniversalGroupBackend.java:129)
com.google.gerrit.server.project.ProjectControl.match(ProjectControl.java:493)

Change the HashMap to a ConcurrentHashMap to handle concurrent access.

Change-Id: I36f654281b7a1d7126936d86d64e6827d8987577
Fix NPE in auto-detection of SSH module of plugin

A NOP-ModuleCreator is introduced to make the coding more robust.

Change-Id: I0adf995e13d8f95d961c5ded842b96cd1d57eb96
Fix compilaion error

I0adf995e1 broke compilation.

Change-Id: I0103c4e348733fc9f07ebe4fb0d749e2136d9a6a
Simplify autoCloseCommits() handling of exact SHA-1 matches

Ref objects inside of the byCommit map cannot be null.
The ref != null test is always true, and can be dropped.

While we are cleaning up this code, inline the Set<Ref>
that is used only for the loop control.

Change-Id: I8fc9a62672b94203ababf8f5b529ded727cf700a
Extract path info from requests without decoding

The fix for Guice issue #745[1] causes getPathInfo() within the
GuiceFilter to return decoded values, eliminating the difference
between "foo/bar" and "foo%2Fbar". This is in spec with the servlet
standard, whose javadoc for getPathInfo[2] states that the return
value be "decoded by the web container".

Work around this by extracting the path part directly from the request
URI, which is unmodified by the container. This is copying the Guice
behavior prior to the bugfix. We do this with a static method rather
than using our own HttpServletRequestWrapper as we don't want to
produce a request wrapper that is not in spec.

[1] https://github.com/google/guice/issues/745
[2] http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()

Change-Id: I48fb32710d45f573fb167c6344ad76541672858c
Lazily load the changes byKey map in autoCloseChanges

When a large number of commits are merged in from an upstream Git
repository that does not use Gerrit there may be no Change-Id lines
found in the revision range being traversed.

Avoid scanning the database to query out open changes until at
least one commit is found that has a Change-Id footer.

Change-Id: I91d2647691daef9755ade2bfbf0d3c25eefd02db
Use refsByChange Multimap to build changeRefsById in ReceiveCommits

During autoCloseChanges if any commit is matched a ReplaceRequest
will be created to handle updating the change and closing it. The
class constructor uses refsByChange to build its revisions map.

Reusing refsByChange allows the ref space to be scanned once
and be pre-filtered for valid PatchSet refs.

Change-Id: I64262bb014376b6583d6197e3bc594d26c54562e
Merge changes from topic 'rc-cleanup'

* changes:
  Use refsByChange Multimap to build changeRefsById in ReceiveCommits
  Lazily load the changes byKey map in autoCloseChanges
  Simplify autoCloseCommits() handling of exact SHA-1 matches
  Cache reused values in autoCloseChanges
  Simplify parseBody call when looking at changes to close
  Refactor auto close change filtering in ReceiveCommits
Add hashCode method on LabelVote and PatchLineComment classes

According to FindBugs:

"This class overrides equals(Object), but does not override hashCode(),
and inherits the implementation of hashCode() from java.lang.Object
(which returns the identity hash code, an arbitrary value assigned to
the object by the VM).  Therefore, the class is very likely to violate
the invariant that equal objects must have equal hashcodes."

Add implementations of hashCode.

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

* stable-2.9:
  Fix IncludingGroupMembership.containsAnyOf infinite loop
  Pass ChangeControl into CodeReviewCommit error instances
  Avoid CodeReviewCommit.error() whenever possible
  Update replication plugin to latest revision

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

* stable-2.10:
  Fix IncludingGroupMembership.containsAnyOf infinite loop
  Fix using HTTP methods other than GET from plugins
  Pass ChangeControl into CodeReviewCommit error instances
  Avoid CodeReviewCommit.error() whenever possible
  Update replication plugin to latest revision

Conflicts:
	gerrit-server/src/main/java/com/google/gerrit/server/git/CodeReviewCommit.java

Change-Id: I9c59567bd54a493a5e262e7776df00f1b776b553
Avoid empty web_links element inside of RevisionInfo

Web UI always requests WEB_LINKS from /changes/{id}, but the common
case for a server is to have no special PatchSetWebLink.

Skip the "web_links = []" JSON code that appears in every revision on
the change by setting the list to null.

Skip pointless copying of the computed collection by changing the
return type from WebLinks to clearly be a List<WebLinkInfo>, like
RevisionInfo expects.  This allows direct assignment into the result.

Change-Id: I665e225b5abdd571a0adba8d2a1d318a1926801a