⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svnclient.cpp

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    Pool requestPool;    if(path == NULL)    {        JNIUtil::throwNullPointerException("path");        return;    }    if(name == NULL)    {        JNIUtil::throwNullPointerException("name");        return;    }    propertySet(path, name, (svn_string_t*)NULL, recurse, false);}void SVNClient::propertyCreate(const char *path, const char *name,                                const char *value, bool recurse, bool force){    Pool requestPool;    if(path == NULL)    {        JNIUtil::throwNullPointerException("path");        return;    }    if(name == NULL)    {        JNIUtil::throwNullPointerException("name");        return;    }    if(value == NULL)    {        JNIUtil::throwNullPointerException("value");        return;    }    svn_string_t *val = svn_string_create(value, requestPool.pool());    propertySet(path, name, val, recurse, force);}void SVNClient::propertyCreate(const char *path, const char *name,                                JNIByteArray &value, bool recurse, bool force){    Pool requestPool;    if(path == NULL)    {        JNIUtil::throwNullPointerException("path");        return;    }    if(name == NULL)    {        JNIUtil::throwNullPointerException("name");        return;    }    if(value.isNull())    {        JNIUtil::throwNullPointerException("value");        return;    }    svn_string_t *val = svn_string_ncreate((const char *)value.getBytes(),                                             value.getLength(),                                             requestPool.pool());    propertySet(path, name, val, recurse, force);}void SVNClient::diff(const char *target1, Revision &revision1,                    const char *target2, Revision &revision2,                    const char *outfileName,bool recurse, bool ignoreAncestry,                    bool noDiffDelete, bool force){    Pool requestPool;    svn_error_t *err = NULL;    apr_array_header_t *options;    if(target1 == NULL)    {        JNIUtil::throwNullPointerException("target1");        return;    }    if(target2 == NULL)    {        JNIUtil::throwNullPointerException("target2");        return;    }    if(outfileName == NULL)    {        JNIUtil::throwNullPointerException("outfileName");        return;    }    svn_client_ctx_t *ctx = getContext(NULL);    if(ctx == NULL)        return;    Path intTarget1(target1);    svn_error_t *Err = intTarget1.error_occured();    if(Err != NULL)    {        JNIUtil::handleSVNError(Err);        return;    }    Path intTarget2(target2);    Err = intTarget2.error_occured();    if(Err != NULL)    {        JNIUtil::handleSVNError(Err);        return;    }    apr_file_t *outfile = NULL;    apr_status_t rv;    rv = apr_file_open(&outfile,                        svn_path_internal_style (outfileName,                                                 requestPool.pool()),                       APR_CREATE|APR_WRITE|APR_TRUNCATE , APR_OS_DEFAULT,                       requestPool.pool());    if (rv != APR_SUCCESS)    {        err = svn_error_create(rv, NULL,_("Cannot open file."));        JNIUtil::handleSVNError(err);        return;    }    // we don't use any options    options = svn_cstring_split ("", " \t\n\r", TRUE, requestPool.pool());    Err = svn_client_diff2 (                            options,    // options                            intTarget1.c_str(),                            revision1.revision(),                            intTarget2.c_str(),                            revision2.revision(),                            recurse ? TRUE : FALSE,                            ignoreAncestry ? TRUE : FALSE,                            noDiffDelete ? TRUE : FALSE,                            force  ? TRUE : FALSE,                            outfile,                            NULL,                              // errFile (not needed when using default diff)                            ctx,                            requestPool.pool());    rv = apr_file_close(outfile);    if (rv != APR_SUCCESS)    {        err = svn_error_create(rv, NULL,_("Cannot close file."));         JNIUtil::handleSVNError(err);        return;    }    if(Err != NULL)    {         JNIUtil::handleSVNError(Err);        return;    }}void SVNClient::diff(const char *target, Revision &pegRevision,                    Revision &startRevision, Revision &endRevision,                    const char *outfileName,bool recurse, bool ignoreAncestry,                    bool noDiffDelete, bool force){    Pool requestPool;    svn_error_t *err = NULL;    apr_array_header_t *options;    if(target == NULL)    {        JNIUtil::throwNullPointerException("target");        return;    }    if(outfileName == NULL)    {        JNIUtil::throwNullPointerException("outfileName");        return;    }    svn_client_ctx_t *ctx = getContext(NULL);    if(ctx == NULL)        return;    Path intTarget(target);    svn_error_t *Err = intTarget.error_occured();    if(Err != NULL)    {        JNIUtil::handleSVNError(Err);        return;    }    apr_file_t *outfile = NULL;    apr_status_t rv;    rv = apr_file_open(&outfile,                        svn_path_internal_style (outfileName,                                                 requestPool.pool()),                       APR_CREATE|APR_WRITE|APR_TRUNCATE , APR_OS_DEFAULT,                       requestPool.pool());    if (rv != APR_SUCCESS)    {        err = svn_error_create(rv, NULL,_("Cannot open file."));        JNIUtil::handleSVNError(err);        return;    }    // we don't use any options    options = svn_cstring_split ("", " \t\n\r", TRUE, requestPool.pool());    Err = svn_client_diff_peg2 (                            options,    // options                            intTarget.c_str(),                            pegRevision.revision(),                            startRevision.revision(),                            endRevision.revision(),                            recurse ? TRUE : FALSE,                            ignoreAncestry ? TRUE : FALSE,                            noDiffDelete ? TRUE : FALSE,                            force  ? TRUE : FALSE,                            outfile,                            NULL,                              // errFile (not needed when using default diff)                            ctx,                            requestPool.pool());    rv = apr_file_close(outfile);    if (rv != APR_SUCCESS)    {        err = svn_error_create(rv, NULL,_("Cannot close file."));         JNIUtil::handleSVNError(err);        return;    }    if(Err != NULL)    {         JNIUtil::handleSVNError(Err);        return;    }}svn_client_ctx_t * SVNClient::getContext(const char *message){    apr_pool_t *pool = JNIUtil::getRequestPool()->pool();    svn_auth_baton_t *ab;    svn_client_ctx_t *ctx;    svn_error_t *err = NULL;    if (( err = svn_client_create_context(&ctx, pool)))    {        JNIUtil::handleSVNError(err);        return NULL;    }    apr_array_header_t *providers      = apr_array_make (pool, 10, sizeof (svn_auth_provider_object_t *));    /* The main disk-caching auth providers, for both       'username/password' creds and 'username' creds.  */    svn_auth_provider_object_t *provider;#ifdef WIN32    svn_client_get_windows_simple_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;#endif    svn_client_get_simple_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;    svn_client_get_username_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;    /* The server-cert, client-cert, and client-cert-password providers. */    svn_client_get_ssl_server_trust_file_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;    svn_client_get_ssl_client_cert_file_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;    svn_client_get_ssl_client_cert_pw_file_provider (&provider, pool);    APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;    if(m_prompter != NULL)    {         /* Two basic prompt providers: username/password, and just username.*/        provider = m_prompter->getProviderSimple();        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;        provider = m_prompter->getProviderUsername();        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;        /* Three ssl prompt providers, for server-certs, client-certs,           and client-cert-passphrases.  */        provider = m_prompter->getProviderServerSSLTrust();        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;        provider = m_prompter->getProviderClientSSL();        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;        provider = m_prompter->getProviderClientSSLPassword();        APR_ARRAY_PUSH (providers, svn_auth_provider_object_t *) = provider;      }    /* Build an authentication baton to give to libsvn_client. */    svn_auth_open (&ab, providers, pool);    /* Place any default --username or --password credentials into the       auth_baton's run-time parameter hash.  ### Same with --no-auth-cache? */    if (!m_userName.empty())      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_USERNAME,                             m_userName.c_str());    if (!m_passWord.empty())      svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD,                             m_passWord.c_str());    ctx->auth_baton = ab;    ctx->notify_func = Notify::notify;    ctx->notify_baton = m_notify;    ctx->log_msg_func = getCommitMessage;    ctx->log_msg_baton = getCommitMessageBaton(message);    ctx->cancel_func = checkCancel;    m_cancelOperation = false;    ctx->cancel_baton = this;    const char *configDir = m_configDir.c_str();    if(m_configDir.length() == 0)        configDir = NULL;    if (( err =             svn_config_get_config (&(ctx->config), configDir, pool)))    {        JNIUtil::handleSVNError(err);        return NULL;    }    ctx->notify_func2= Notify2::notify;    ctx->notify_baton2 = m_notify2;    return ctx;}svn_error_t *SVNClient::getCommitMessage(const char **log_msg,                                          const char **tmp_file,                                         apr_array_header_t *commit_items,                                          void *baton,                                         apr_pool_t *pool){    *log_msg = NULL;    *tmp_file = NULL;    log_msg_baton *lmb = (log_msg_baton *) baton;    if (lmb && lmb->messageHandler)    {        jstring jmsg = lmb->messageHandler->getCommitMessage(commit_items);        if(jmsg != NULL)        {            JNIStringHolder msg(jmsg);            *log_msg = apr_pstrdup (pool, msg);        }        return SVN_NO_ERROR;    }    else if (lmb && lmb->message)    {        *log_msg = apr_pstrdup (pool, lmb->message);        return SVN_NO_ERROR;    }    return SVN_NO_ERROR;}void *SVNClient::getCommitMessageBaton(const char *message){    if(message != NULL || m_commitMessage)    {        log_msg_baton *baton = (log_msg_baton *)            apr_palloc (JNIUtil::getRequestPool()->pool(), sizeof (*baton));        baton->message = message;        baton->messageHandler = m_commitMessage;        return baton;    }    return NULL;}jobject SVNClient::createJavaStatus(const char *path, svn_wc_status2_t *status){    JNIEnv *env = JNIUtil::getEnv();    jclass clazz = env->FindClass(JAVA_PACKAGE"/Status");    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    static jmethodID mid = 0;    if(mid == 0)    {        mid = env->GetMethodID(clazz, "<init>",            "(Ljava/lang/String;Ljava/lang/String;IJJJLjava/lang/String;IIIIZZ"             "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;"             "Ljava/lang/String;JZLjava/lang/String;Ljava/lang/String;"             "Ljava/lang/String;JLorg/tigris/subversion/javahl/Lock;"             "JJILjava/lang/String;)V");        if(JNIUtil::isJavaExceptionThrown())        {            return NULL;        }    }    jstring jPath = JNIUtil::makeJString(path);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jstring jUrl = NULL;    jint jNodeKind = org_tigris_subversion_javahl_NodeKind_unknown;    jlong jRevision = org_tigris_subversion_javahl_Revision_SVN_INVALID_REVNUM;    jlong jLastChangedRevision =                     org_tigris_subversion_javahl_Revision_SVN_INVALID_REVNUM;    jlong jLastChangedDate = 0;    jstring jLastCommitAuthor = NULL;    jint jTextType = org_tigris_subversion_javahl_StatusKind_none;    jint jPropType = org_tigris_subversion_javahl_StatusKind_none;    jint jRepositoryTextType = org_tigris_subversion_javahl_StatusKind_none;    jint jRepositoryPropType = org_tigris_subversion_javahl_StatusKind_none;    jboolean jIsLocked = JNI_FALSE;    jboolean jIsCopied = JNI_FALSE;    jboolean jIsSwitched = JNI_FALSE;    jstring jConflictOld = NULL;    jstring jConflictNew = NULL;    jstring jConflictWorking = NULL;    jstring jURLCopiedFrom = NULL;    jlong jRevisionCopiedFrom =                     org_tigris_subversion_javahl_Revision_SVN_INVALID_REVNUM;    jstring jLockToken = NULL;    jstring jLockComment = NULL;    jstring jLockOwner = NULL;    jlong jLockCreationDate = 0;    jobject jLock = NULL;    jlong jOODLastCmtRevision =                    org_tigris_subversion_javahl_Revision_SVN_INVALID_REVNUM;    jlong jOODLastCmtDate = 0;    jint jOODKind = org_tigris_subversion_javahl_NodeKind_none;    jstring jOODLastCmtAuthor = NULL;    if(status != NULL)    {        jTextType = EnumMapper::mapStatusKind(status->text_status);        jPropType = EnumMapper::mapStatusKind(status->prop_status);        jRepositoryTextType = EnumMapper::mapStatusKind(status->repos_text_status);        jRepositoryPropType = EnumMapper::mapStatusKind(status->repos_prop_status);        jIsCopied = (status->copied == 1) ? JNI_TRUE: JNI_FALSE;        jIsLocked = (status->locked == 1) ? JNI_TRUE: JNI_FALSE;        jIsSwitched = (status->switched == 1) ? JNI_TRUE: JNI_FALSE;        jLock = createJavaLock(status->repos_lock);        if(JNIUtil::isJavaExceptionThrown())        {            return NULL;        }        jUrl = JNIUtil::makeJString(status->url);        if(JNIUtil::isJavaExceptionThrown())        {            return NULL;        }        jOODLastCmtRevision = status->ood_last_cmt_rev;        jOODLastCmtDate = status->ood_last_cmt_date;        jOODKind = EnumMapper::mapNodeKind(status->ood_kind);        jOODLastCmtAuthor = JNIUtil::makeJString(status->ood_last_cmt_author);        if(JNIUtil::isJavaExceptionThrown())        {            return NULL;        }        svn_wc_entry_t * entry = status->entry;        if (entry != NULL)        {            jNodeKind = EnumMapper::mapNodeKind(entry->kind);            jRevision = entry->revision;            jLastChangedRevision = entry->cmt_rev;            jLastChangedDate = entry->cmt_date;            jLastCommitAuthor = JNIUtil::makeJString(entry->cmt_author);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -