Check permission before denying access due to concurrent use.

If a repository is being shared, anyone wanting to use it must have write
permissions. The lock logic only checks for a successful lock and not the
ability to create a lockfile.