📄 svnadmin.cpp
字号:
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 *); /* 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; } /* 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; }}jobjectArray SVNAdmin::lslocks(const char *path){ Pool requestPool; if(path == NULL) { JNIUtil::throwNullPointerException("path"); return NULL; } path = svn_path_internal_style(path, requestPool.pool()); svn_repos_t *repos; svn_fs_t *fs; apr_hash_t *locks; apr_hash_index_t *hi; svn_error_t *err = svn_repos_open (&repos, path, requestPool.pool()); if(err != SVN_NO_ERROR) { JNIUtil::handleSVNError(err); return NULL; } fs = svn_repos_fs (repos); /* Fetch all locks on or below the root directory. */ err = svn_repos_fs_get_locks (&locks, repos, "/", NULL, NULL, requestPool.pool()); if(err != SVN_NO_ERROR) { JNIUtil::handleSVNError(err); return NULL; } int count = apr_hash_count (locks); JNIEnv *env = JNIUtil::getEnv(); jclass clazz = env->FindClass(JAVA_PACKAGE"/Lock"); if(JNIUtil::isJavaExceptionThrown()) { return NULL; } jobjectArray ret = env->NewObjectArray(count, clazz, NULL); if(JNIUtil::isJavaExceptionThrown()) { return NULL; } env->DeleteLocalRef(clazz); if(JNIUtil::isJavaExceptionThrown()) { return NULL; } int i = 0; for (hi = apr_hash_first (requestPool.pool(), locks); hi; hi = apr_hash_next (hi),i++) { const void *key; void *val; apr_hash_this (hi, &key, NULL, &val); svn_lock_t *lock = (svn_lock_t *)val; jobject jLock = SVNClient::createJavaLock(lock); env->SetObjectArrayElement(ret, i, jLock); if(JNIUtil::isJavaExceptionThrown()) { return NULL; } env->DeleteLocalRef(jLock); if(JNIUtil::isJavaExceptionThrown()) { return NULL; } } return ret;}void SVNAdmin::rmlocks(const char *path, Targets &locks){ Pool requestPool; apr_pool_t *pool = requestPool.pool(); 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_access_t *access; 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); const char *username; /* svn_fs_unlock() demands that some username be associated with the filesystem, so just use the UID of the person running 'svnadmin'.*/ { apr_uid_t uid; apr_gid_t gid; char *un; if (apr_uid_current (&uid, &gid, pool) == APR_SUCCESS && apr_uid_name_get (&un, uid, pool) == APR_SUCCESS) { err = svn_utf_cstring_to_utf8 (&username, un, pool); svn_error_clear (err); if (err) username = "administrator"; } } /* Create an access context describing the current user. */ err = svn_fs_create_access (&access, username, pool); if(err != SVN_NO_ERROR) { JNIUtil::handleSVNError(err); return; } /* Attach the access context to the filesystem. */ err = svn_fs_set_access (fs, access); if(err != SVN_NO_ERROR) { JNIUtil::handleSVNError(err); return; } apr_pool_t *subpool = svn_pool_create (pool); const apr_array_header_t *args = locks.array(requestPool); for (int i = 0; i < args->nelts; i++) { const char *lock_path = APR_ARRAY_IDX (args, i, const char *); svn_lock_t *lock; /* Fetch the path's svn_lock_t. */ err = svn_fs_get_lock (&lock, fs, lock_path, subpool); if (err) goto move_on; if (! lock) { continue; } /* Now forcibly destroy the lock. */ err = svn_fs_unlock (fs, lock_path, lock->token, 1 /* force */, subpool); if (err) goto move_on; move_on: if (err) { svn_error_clear (err); } svn_pool_clear (subpool); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -