Beispiel #1
0
void SVNRepos::create(File &path, bool disableFsyncCommits,
                      bool keepLogs, File &configPath,
                      const char *fstype)
{
  SVN::Pool requestPool;
  svn_repos_t *repos;
  apr_hash_t *config;
  apr_hash_t *fs_config = apr_hash_make(requestPool.getPool());

  if (path.isNull())
    {
      JNIUtil::throwNullPointerException("path");
      return;
    }

  apr_hash_set(fs_config, SVN_FS_CONFIG_BDB_TXN_NOSYNC,
               APR_HASH_KEY_STRING,
               (disableFsyncCommits? "1" : "0"));

  apr_hash_set(fs_config, SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE,
               APR_HASH_KEY_STRING,
               (keepLogs ? "0" : "1"));
  apr_hash_set(fs_config, SVN_FS_CONFIG_FS_TYPE,
               APR_HASH_KEY_STRING, fstype);

  SVN_JNI_ERR(svn_config_get_config(&config,
                                    configPath.getInternalStyle(requestPool),
                                    requestPool.getPool()),);
  SVN_JNI_ERR(svn_repos_create(&repos, path.getInternalStyle(requestPool),
                               NULL, NULL, config, fs_config,
                               requestPool.getPool()), );
}
void
ClientContext::setConfigDirectory(const char *configDir)
{
    // A change to the config directory may necessitate creation of
    // the config templates.
    SVN::Pool requestPool;
    SVN_JNI_ERR(svn_config_ensure(configDir, requestPool.getPool()), );

    m_configDir = (configDir == NULL ? "" : configDir);
    m_context->config = NULL;
}
Beispiel #3
0
void SVNRepos::deltify(File &path, Revision &revStart, Revision &revEnd)
{
  SVN::Pool requestPool;
  svn_repos_t *repos;
  svn_fs_t *fs;
  svn_revnum_t start = SVN_INVALID_REVNUM, end = SVN_INVALID_REVNUM;
  svn_revnum_t youngest, revision;
  SVN::Pool revisionPool;

  if (path.isNull())
    {
      JNIUtil::throwNullPointerException("path");
      return;
    }

  SVN_JNI_ERR(svn_repos_open3(&repos,
                              path.getInternalStyle(requestPool), NULL,
                              requestPool.getPool(),
                              requestPool.getPool()), );
  fs = svn_repos_fs(repos);
  SVN_JNI_ERR(svn_fs_youngest_rev(&youngest, fs, requestPool.getPool()), );

  if (revStart.revision()->kind == svn_opt_revision_number)
    /* ### We only handle revision numbers right now, not dates. */
    start = revStart.revision()->value.number;
  else if (revStart.revision()->kind == svn_opt_revision_head)
    start = youngest;
  else
    start = SVN_INVALID_REVNUM;

  if (revEnd.revision()->kind == svn_opt_revision_number)
    end = revEnd.revision()->value.number;
  else if (revEnd.revision()->kind == svn_opt_revision_head)
    end = youngest;
  else
    end = SVN_INVALID_REVNUM;

  /* Fill in implied revisions if necessary. */
  if (start == SVN_INVALID_REVNUM)
    start = youngest;
  if (end == SVN_INVALID_REVNUM)
    end = start;

  if (start > end)
    {
      SVN_JNI_ERR(svn_error_create
                  (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                   _("First revision cannot be higher than second")), );
    }
ClientContext::ClientContext(jobject jsvnclient, SVN::Pool &pool)
    : m_prompter(NULL),
      m_cancelOperation(false)
{
    JNIEnv *env = JNIUtil::getEnv();

    /* Grab a global reference to the Java object embedded in the parent Java
       object. */
    static jfieldID ctxFieldID = 0;
    if (ctxFieldID == 0)
    {
        jclass clazz = env->GetObjectClass(jsvnclient);
        if (JNIUtil::isJavaExceptionThrown())
            return;

        ctxFieldID = env->GetFieldID(clazz, "clientContext",
                                "L"JAVA_PACKAGE"/SVNClient$ClientContext;");
        if (JNIUtil::isJavaExceptionThrown() || ctxFieldID == 0)
            return;

        env->DeleteLocalRef(clazz);
    }

    jobject jctx = env->GetObjectField(jsvnclient, ctxFieldID);
    if (JNIUtil::isJavaExceptionThrown())
        return;

    m_jctx = env->NewGlobalRef(jctx);
    if (JNIUtil::isJavaExceptionThrown())
        return;

    env->DeleteLocalRef(jctx);

    SVN_JNI_ERR(svn_client_create_context(&m_context, pool.getPool()),
                );

    /* Clear the wc_ctx as we don't want to maintain this unconditionally
       for compatibility reasons */
    SVN_JNI_ERR(svn_wc_context_destroy(m_context->wc_ctx),
                );
    m_context->wc_ctx = NULL;

    /* None of the following members change during the lifetime of
       this object. */
    m_context->notify_func = NULL;
    m_context->notify_baton = NULL;
    m_context->log_msg_func3 = CommitMessage::callback;
    m_context->log_msg_baton3 = NULL;
    m_context->cancel_func = checkCancel;
    m_context->cancel_baton = this;
    m_context->notify_func2= notify;
    m_context->notify_baton2 = m_jctx;
    m_context->progress_func = progress;
    m_context->progress_baton = m_jctx;
    m_context->conflict_func2 = resolve;
    m_context->conflict_baton2 = m_jctx;

    m_context->client_name = "javahl";
    m_pool = &pool;
}
ClientContext::ClientContext(jobject jsvnclient, SVN::Pool &pool)
    : OperationContext(pool)
{
    static jfieldID ctxFieldID = 0;
    attachJavaObject(jsvnclient, JAVAHL_ARG("/SVNClient$ClientContext;"), "clientContext", &ctxFieldID);

    SVN_JNI_ERR(svn_client_create_context2(&m_context, NULL,
                                           pool.getPool()),
                );

    /* Clear the wc_ctx as we don't want to maintain this unconditionally
       for compatibility reasons */
    SVN_JNI_ERR(svn_wc_context_destroy(m_context->wc_ctx),
                );
    m_context->wc_ctx = NULL;

    /* None of the following members change during the lifetime of
       this object. */
    m_context->notify_func = NULL;
    m_context->notify_baton = NULL;
    m_context->log_msg_func3 = CommitMessage::callback;
    m_context->log_msg_baton3 = NULL;
    m_context->cancel_func = checkCancel;
    m_context->cancel_baton = this;
    m_context->notify_func2= notify;
    m_context->notify_baton2 = m_jctx;
    m_context->progress_func = progress;
    m_context->progress_baton = m_jctx;
    m_context->conflict_func2 = resolve;
    m_context->conflict_baton2 = m_jctx;

    m_context->client_name = getClientName();

    if (m_jtunnelcb)
      {
        m_context->check_tunnel_func = checkTunnel;
        m_context->open_tunnel_func = openTunnel;
        m_context->tunnel_baton = m_jtunnelcb;
      }
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_util_DiffLib_nativeFileDiff(
    JNIEnv* env, jobject jthis,
    jstring joriginal_file,
    jstring jmodified_file,

    jint jignore_space_ordinal,
    jboolean jignore_eol_style,
    jboolean jshow_c_function,

    jstring joriginal_header,
    jstring jmodified_header,
    jstring jheader_encoding,
    jstring jrelative_to_dir,

    jobject jresult_stream)
{
  JNIEntry(DiffLib, nativeFileDiff);

  // Using a "global" request pool since we don't keep a context with
  // its own pool around for these functions.
  SVN::Pool pool;

  Path original(joriginal_file, pool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(original.error_occurred(),);

  Path modified(jmodified_file, pool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(modified.error_occurred(),);

  svn_diff_t* diff;
  svn_diff_file_options_t* diff_options =
    svn_diff_file_options_create(pool.getPool());
  diff_options->ignore_space =
    svn_diff_file_ignore_space_t(jignore_space_ordinal);
  diff_options->ignore_eol_style = svn_boolean_t(jignore_eol_style);
  diff_options->show_c_function = svn_boolean_t(jshow_c_function);
  SVN_JNI_ERR(svn_diff_file_diff_2(&diff,
                                   original.c_str(),
                                   modified.c_str(),
                                   diff_options,
                                   pool.getPool()),);

  JNIStringHolder original_header(joriginal_header);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder modified_header(jmodified_header);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder header_encoding(jheader_encoding);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder relative_to_dir(jrelative_to_dir);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  
  OutputStream result_stream(jresult_stream);

  SVN_JNI_ERR(svn_diff_file_output_unified3(
                  result_stream.getStream(pool), diff,
                  original.c_str(), modified.c_str(),
                  original_header.c_str(), modified_header.c_str(),
                  header_encoding.c_str(), relative_to_dir.c_str(),
                  diff_options->show_c_function,
                  pool.getPool()),);
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_util_DiffLib_nativeFileMerge(
    JNIEnv* env, jobject jthis,
    jstring joriginal_file,
    jstring jmodified_file,
    jstring jlatest_file,

    jint jignore_space_ordinal,
    jboolean jignore_eol_style,
    jboolean jshow_c_function,

    jstring jconflict_original,
    jstring jconflict_modified,
    jstring jconflict_latest,
    jstring jconflict_separator,
    jint jconflict_style_ordinal,

    jobject jresult_stream)
{
  JNIEntry(DiffLib, nativeFileMerge);

  // Using a "global" request pool since we don't keep a context with
  // its own pool around for these functions.
  SVN::Pool pool;

  Path original(joriginal_file, pool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(original.error_occurred(),);

  Path modified(jmodified_file, pool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(modified.error_occurred(),);

  Path latest(jlatest_file, pool);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  SVN_JNI_ERR(latest.error_occurred(),);

  svn_diff_t* diff;
  svn_diff_file_options_t* diff_options =
    svn_diff_file_options_create(pool.getPool());
  diff_options->ignore_space =
    svn_diff_file_ignore_space_t(jignore_space_ordinal);
  diff_options->ignore_eol_style = svn_boolean_t(jignore_eol_style);
  diff_options->show_c_function = svn_boolean_t(jshow_c_function);
  SVN_JNI_ERR(svn_diff_file_diff3_2(&diff,
                                    original.c_str(),
                                    modified.c_str(),
                                    latest.c_str(),
                                    diff_options,
                                    pool.getPool()),);

  JNIStringHolder conflict_original(jconflict_original);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder conflict_modified(jconflict_modified);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder conflict_latest(jconflict_latest);
  if (JNIUtil::isJavaExceptionThrown())
    return;

  JNIStringHolder conflict_separator(jconflict_separator);
  if (JNIUtil::isJavaExceptionThrown())
    return;
  
  OutputStream result_stream(jresult_stream);

  SVN_JNI_ERR(svn_diff_file_output_merge2(
                  result_stream.getStream(pool), diff,
                  original.c_str(), modified.c_str(), latest.c_str(),
                  conflict_original.c_str(),
                  conflict_modified.c_str(),
                  conflict_latest.c_str(),
                  conflict_separator.c_str(),
                  svn_diff_conflict_display_style_t(jconflict_style_ordinal),
                  pool.getPool()),);
}