Avoid repeat creation of repo wrappers we already have

Have the updateRepository method accept a repository instance rather
than fetching one itself. This avoids the need to re-check the repo
is valid, get a lock (etc.) which is redundant given that in both
real usages we already need a handle on the repo anyway.

This is likely to improve the success rates of the file/* endpoints
as they only need to get the lock on their target repo once, rather
than twice per request.

Change-Id: I9bf2dbdbe8681d4c3988c5a21a970d28bd6496de
Make it possible to get shared locks on files

This will make it possible to greatly reduce the lock conflicts on
read-only access to repos, which make up a good portion of the
current failures in this area.

Change-Id: Idd3d7c0ee7d5504d6d91c15f6dd52099be263268
Get a shared lock on read-only repos

There's no need to get an exclusive lock if we aren't going to change
anything in the repo, we only need to be sure that no-one else is
changing it underneath us.

Change-Id: If320abf7ce6c144d57c97b2b691975388f244ba6
Use a ReadOnlyGitRepository for master repos

These are bare anyway, so we don't (generally) write things to them.
By allowing concurrent shared access to these we avoid causing
requests to fail just because they can't get a lock they don't
actually need.

Change-Id: Ica224f0a25fe8e2fc8ac95b2041255183cec3980