Add lock for repository operation.