protected SVNRepository getRepository(
        SCMSourceOwner context,
        SVNURL repoURL,
        StandardCredentials credentials,
        Map<String, Credentials> additionalCredentials,
        ISVNSession session)
        throws SVNException {
      SVNRepository repository = SVNRepositoryFactory.create(repoURL, session);

      ISVNAuthenticationManager sam =
          SubversionSCM.createSvnAuthenticationManager(
              new CredentialsSVNAuthenticationProviderImpl(credentials, additionalCredentials));
      sam =
          new FilterSVNAuthenticationManager(sam) {
            // If there's no time out, the blocking read operation may hang forever, because TCP
            // itself
            // has no timeout. So always use some time out. If the underlying implementation gives
            // us some
            // value (which may come from ~/.subversion), honor that, as long as it sets some
            // timeout value.
            @Override
            public int getReadTimeout(SVNRepository repository) {
              int r = super.getReadTimeout(repository);
              if (r <= 0) r = SubversionSCM.DEFAULT_TIMEOUT;
              return r;
            }
          };
      repository.setTunnelProvider(SubversionSCM.createDefaultSVNOptions());
      repository.setAuthenticationManager(sam);

      return repository;
    }