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

📄 svnadmin.cpp

📁 linux subdivision ying gai ke yi le ba
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    path = svn_path_internal_style(path, requestPool.pool());
    targetPath = svn_path_internal_style(targetPath, requestPool.pool());
    svn_error_t *err = svn_repos_hotcopy (path,
                                          targetPath,
                                          cleanLogs,
                                          requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

}
static void
list_dblogs (const char *path, MessageReceiver &receiver, bool only_unused)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    apr_array_header_t *logfiles;
    int i;
    svn_error_t *err = svn_repos_db_logfiles (&logfiles,
                                              path,
                                              only_unused,
                                              requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

    /* Loop, printing log files.  We append the log paths to the
       repository path, making sure to return everything to the native
       style and encoding before printing. */
    for (i = 0; i < logfiles->nelts; i++)
    {
        const char *log_utf8;
        log_utf8 = svn_path_join (path,
                                  APR_ARRAY_IDX (logfiles, i, const char *),
                                  requestPool.pool());
        log_utf8 = svn_path_local_style (log_utf8, requestPool.pool());
        receiver.receiveMessage(log_utf8);
    }
}

void SVNAdmin::listDBLogs(const char *path, MessageReceiver &messageReceiver)
{
    list_dblogs(path, messageReceiver, false);
}

void SVNAdmin::listUnusedDBLogs(const char *path, MessageReceiver &messageReceiver)
{
    list_dblogs(path, messageReceiver, true);
}

void SVNAdmin::load(const char *path, Inputer &dataIn, Outputer &messageOut, bool ignoreUUID, bool forceUUID, const char *relativePath)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_repos_t *repos;
    enum svn_repos_load_uuid uuid_action;
    if(ignoreUUID)
        uuid_action = svn_repos_load_uuid_ignore;
    else if(forceUUID)
        uuid_action = svn_repos_load_uuid_force;
    svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

    err = svn_repos_load_fs (repos, dataIn.getStream(requestPool), 
                             messageOut.getStream(requestPool),
                             uuid_action, relativePath,
                             NULL, NULL, requestPool.pool());

    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

}

void SVNAdmin::lstxns(const char *path, MessageReceiver &messageReceiver)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_repos_t *repos;
    svn_fs_t *fs;
    apr_array_header_t *txns;
    int i;

    svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }
    fs = svn_repos_fs (repos);
    err = svn_fs_list_transactions (&txns, fs, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

    /* Loop, printing revisions. */
    for (i = 0; i < txns->nelts; i++)
    {
        messageReceiver.receiveMessage(APR_ARRAY_IDX (txns, i, const char *));
    }


}

jlong SVNAdmin::recover(const char *path)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return -1;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_revnum_t youngest_rev;
    svn_repos_t *repos;

    svn_error_t *err = svn_repos_recover2 (path, FALSE, NULL, NULL,
                                           requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return -1;
    }

    /* Since db transactions may have been replayed, it's nice to tell
       people what the latest revision is.  It also proves that the
       recovery actually worked. */
    err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return -1;
    }
    err = svn_fs_youngest_rev (&youngest_rev, svn_repos_fs (repos), 
                               requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return -1;
    }
    return youngest_rev;
}

void SVNAdmin::rmtxns(const char *path, Targets &transactions)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_repos_t *repos;
    svn_fs_t *fs;
    svn_fs_txn_t *txn;
    const apr_array_header_t *args;
    int i;
    apr_pool_t *transactionPool = svn_pool_create (requestPool.pool());

    svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }
    fs = svn_repos_fs (repos);

    args = transactions.array(requestPool);
    /* All the rest of the arguments are transaction names. */
    for (i = 0; i < args->nelts; i++)
    {
        const char *txn_name = APR_ARRAY_IDX (args, i, const char *);
        svn_error_t *err;

        /* Try to open the txn.  If that succeeds, try to abort it. */
        err = svn_fs_open_txn (&txn, fs, txn_name, transactionPool);
        if (! err)
            err = svn_fs_abort_txn (txn, transactionPool);

        /* If either the open or the abort of the txn fails because that
           transaction is dead, just try to purge the thing.  Else,
           there was either an error worth reporting, or not error at
           all.  */
        if (err && (err->apr_err == SVN_ERR_FS_TRANSACTION_DEAD))
        {
            svn_error_clear (err);
            err = svn_fs_purge_txn (fs, txn_name, transactionPool);
        }

        /* If we had a real from the txn open, abort, or purge, we clear
           that error and just report to the user that we had an issue
           with this particular txn. */
        if (err)
        {
            JNIUtil::handleSVNError(err);
            return;
        }
        svn_pool_clear (transactionPool);
    }

}

void SVNAdmin::setLog(const char *path, Revision &revision, 
                      const char *message, bool bypassHooks)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    if(message == NULL)
    {
        JNIUtil::throwNullPointerException("message");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_repos_t *repos;
    svn_string_t *log_contents = svn_string_create (message, 
                                                    requestPool.pool());

    if (revision.revision()->kind != svn_opt_revision_number)
    {
        JNIUtil::handleSVNError(
            svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                              _("Missing revision")));
        return;
    }
    else if (revision.revision()->kind != svn_opt_revision_unspecified)
    { 
        JNIUtil::handleSVNError(
            svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                              _("Only one revision allowed")));
      return;
    }
    /* Open the filesystem  */
    svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }

    /* If we are bypassing the hooks system, we just hit the filesystem
       directly. */
    if (bypassHooks)
    {
        svn_fs_t *fs = svn_repos_fs (repos);
        err = svn_fs_change_rev_prop
               (fs, revision.revision()->value.number,
                SVN_PROP_REVISION_LOG, log_contents, requestPool.pool());
    }
    else
    {
        err = svn_repos_fs_change_rev_prop
               (repos, revision.revision()->value.number,
                NULL, SVN_PROP_REVISION_LOG, log_contents, requestPool.pool());
    }
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }
}

void SVNAdmin::verify(const char *path, Outputer &messageOut, 
                      Revision &revisionStart, Revision &revisionEnd)
{
    Pool requestPool;
    if(path == NULL)
    {
        JNIUtil::throwNullPointerException("path");
        return;
    }
    path = svn_path_internal_style(path, requestPool.pool());
    svn_repos_t *repos;
    svn_revnum_t youngest;

    /* This whole process is basically just a dump of the repository
       with no interest in the output. */
    svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }
    err = svn_fs_youngest_rev (&youngest, svn_repos_fs (repos), 
                               requestPool.pool());
    if(err != SVN_NO_ERROR)
    { 
        JNIUtil::handleSVNError(err);
        return;
    }
    err = svn_repos_dump_fs (repos, NULL, messageOut.getStream(requestPool),
                             0, youngest, FALSE, NULL, NULL, 
                             requestPool.pool());
    if(err != SVN_NO_ERROR)
    {
        JNIUtil::handleSVNError(err);
        return;
    }
}

⌨️ 快捷键说明

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