You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/09/15 21:32:38 UTC
svn commit: r997472 [2/41] - in /subversion/branches/py-tests-as-modules: ./
build/ build/ac-macros/ build/generator/ build/generator/templates/
contrib/server-side/ notes/ notes/tree-conflicts/ notes/wc-ng/
subversion/bindings/javahl/native/ subversio...
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.cpp Wed Sep 15 19:32:26 2010
@@ -28,9 +28,10 @@
#include "CreateJ.h"
#include "EnumMapper.h"
#include "JNIUtil.h"
+#include "JNIStringHolder.h"
+
#include <apr_tables.h>
#include "svn_client.h"
-#include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
CommitMessage::CommitMessage(jobject jcommitMessage)
{
@@ -39,90 +40,46 @@ CommitMessage::CommitMessage(jobject jco
CommitMessage::~CommitMessage()
{
- // Since the m_jcommitMessage is a global reference, it has to be
- // deleted to allow the Java garbage collector to reclaim the
- // object.
- if (m_jcommitMessage!= NULL)
- {
- JNIEnv *env = JNIUtil::getEnv();
- env->DeleteGlobalRef(m_jcommitMessage);
- }
+ // No need to delete the local reference
}
-CommitMessage *CommitMessage::makeCCommitMessage(jobject jcommitMessage)
+svn_error_t *
+CommitMessage::callback(const char **log_msg,
+ const char **tmp_file,
+ const apr_array_header_t *commit_items,
+ void *baton,
+ apr_pool_t *pool)
{
- // If there is no object passed into this method, there is no need
- // for a C++ holding object.
- if (jcommitMessage == NULL)
- return NULL;
-
- // Sanity check, that the passed Java object implements the right
- // interface.
- JNIEnv *env = JNIUtil::getEnv();
- jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitMessage");
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- if (!env->IsInstanceOf(jcommitMessage, clazz))
- {
- env->DeleteLocalRef(clazz);
- return NULL;
- }
- env->DeleteLocalRef(clazz);
-
- // Since the reference is longer needed then the duration of the
- // SVNClient.commtMessage, the local reference has to be converted
- // to a global reference.
- jobject myCommitMessage = env->NewGlobalRef(jcommitMessage);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- // create & return the holding object
- return new CommitMessage(myCommitMessage);
+ if (baton && ((CommitMessage *)baton)->m_jcommitMessage)
+ return ((CommitMessage *)baton)->getCommitMessage(log_msg, tmp_file,
+ commit_items, pool);
+
+ *log_msg = NULL;
+ *tmp_file = NULL;
+ return SVN_NO_ERROR;
}
-/**
- * Call the Java callback method to retrieve the commit message
- * @param commit_items the array of the items of this commit
- * @returns the commit message
- */
-jstring
-CommitMessage::getCommitMessage(const apr_array_header_t *commit_items)
+svn_error_t *
+CommitMessage::getCommitMessage(const char **log_msg,
+ const char **tmp_file,
+ const apr_array_header_t *commit_items,
+ apr_pool_t *pool)
{
+ *tmp_file = NULL;
JNIEnv *env = JNIUtil::getEnv();
- // create an Java array for the commit items
- jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitItem");
- if (JNIUtil::isExceptionThrown())
- return NULL;
-
- // Java method ids will not change during the time this library is
- // loaded, so they can be cached.
-
- // Get the method id for the CommitItem constructor.
- static jmethodID midConstructor = 0;
- if (midConstructor == 0)
- {
- midConstructor = env->GetMethodID(clazz, "<init>",
- "(Ljava/lang/String;"
- "L"JAVA_PACKAGE"/NodeKind;"
- "ILjava/lang/String;"
- "Ljava/lang/String;J)V");
- if (JNIUtil::isExceptionThrown())
- return NULL;
- }
// get the method if for the CommitMessage callback method
static jmethodID midCallback = 0;
if (midCallback == 0)
{
- jclass clazz2 = env->FindClass(JAVA_PACKAGE"/CommitMessage");
+ jclass clazz2 = env->FindClass(JAVA_PACKAGE"/callback/CommitMessageCallback");
if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ return SVN_NO_ERROR;
midCallback = env->GetMethodID(clazz2, "getLogMessage",
"(Ljava/util/Set;)Ljava/lang/String;");
if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ return SVN_NO_ERROR;
env->DeleteLocalRef(clazz2);
}
@@ -134,65 +91,26 @@ CommitMessage::getCommitMessage(const ap
svn_client_commit_item3_t *item =
APR_ARRAY_IDX(commit_items, i, svn_client_commit_item3_t *);
- // convert the commit item members to the match Java members
- jstring jpath = JNIUtil::makeJString(item->path);
-
- jobject jnodeKind = EnumMapper::mapNodeKind(item->kind);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- jint jstateFlags = 0;
- if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)
- jstateFlags |=
- org_apache_subversion_javahl_CommitItemStateFlags_Add;
- if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
- jstateFlags |=
- org_apache_subversion_javahl_CommitItemStateFlags_Delete;
- if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_TEXT_MODS)
- jstateFlags |=
- org_apache_subversion_javahl_CommitItemStateFlags_TextMods;
- if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_PROP_MODS)
- jstateFlags |=
- org_apache_subversion_javahl_CommitItemStateFlags_PropMods;
- if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_IS_COPY)
- jstateFlags |=
- org_apache_subversion_javahl_CommitItemStateFlags_IsCopy;
-
- jstring jurl = JNIUtil::makeJString(item->url);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- jstring jcopyUrl = JNIUtil::makeJString(item->copyfrom_url);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- jlong jcopyRevision = item->revision;
-
- // create the Java object
- jobject jitem = env->NewObject(clazz, midConstructor, jpath,
- jnodeKind, jstateFlags, jurl,
- jcopyUrl, jcopyRevision);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- // release the tempory Java objects
- env->DeleteLocalRef(jpath);
- env->DeleteLocalRef(jnodeKind);
- env->DeleteLocalRef(jurl);
- env->DeleteLocalRef(jcopyUrl);
+ jobject jitem = CreateJ::CommitItem(item);
// store the Java object into the array
jitems.push_back(jitem);
}
- env->DeleteLocalRef(clazz);
-
// call the Java callback method
jstring jmessage = (jstring)env->CallObjectMethod(m_jcommitMessage,
midCallback,
CreateJ::Set(jitems));
if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ return SVN_NO_ERROR;
+
+ if (jmessage != NULL)
+ {
+ JNIStringHolder msg(jmessage);
+ *log_msg = apr_pstrdup(pool, msg);
+ }
+ else
+ *log_msg = NULL;
- return jmessage;
+ return SVN_NO_ERROR;
}
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CommitMessage.h Wed Sep 15 19:32:26 2010
@@ -28,7 +28,8 @@
#define COMMITMESSAGE_H
#include <jni.h>
-struct apr_array_header_t;
+
+#include "svn_client.h"
/**
* This class stores a Java object implementing the CommitMessage
@@ -37,36 +38,25 @@ struct apr_array_header_t;
class CommitMessage
{
public:
- /**
- * Deletes the global reference to m_jcommitMessage.
- */
+ CommitMessage(jobject jcommitMessage);
~CommitMessage();
- jstring getCommitMessage(const apr_array_header_t *commit_items);
-
- /**
- * Create a C++ holding object for the Java object passed into the
- * native code.
- *
- * @param jcommitMessage The local reference to a
- * org.tigris.subversion.javahl.CommitMessage Java commit message
- * object.
- */
- static CommitMessage *makeCCommitMessage(jobject jcommitMessage);
+ static svn_error_t *callback(const char **log_msg,
+ const char **tmp_file,
+ const apr_array_header_t *commit_items,
+ void *baton,
+ apr_pool_t *pool);
+
+ protected:
+ svn_error_t *getCommitMessage(const char **log_msg,
+ const char **tmp_file,
+ const apr_array_header_t *commit_items,
+ apr_pool_t *pool);
private:
- /**
- * A global reference to the Java object, because the reference
- * must be valid longer than the SVNClient.commitMessage call.
- */
+ /* A local reference. */
jobject m_jcommitMessage;
- /**
- * Create a commit message object.
- *
- * @param jcommitMessage The Java object to receive the callback.
- */
- CommitMessage(jobject jcommitMessage);
};
#endif // COMMITMESSAGE_H
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.cpp Wed Sep 15 19:32:26 2010
@@ -32,6 +32,7 @@
#include "RevisionRange.h"
#include "CreateJ.h"
#include "../include/org_apache_subversion_javahl_Revision.h"
+#include "../include/org_apache_subversion_javahl_CommitItemStateFlags.h"
#include "svn_path.h"
#include "private/svn_wc_private.h"
@@ -349,6 +350,62 @@ CreateJ::Lock(const svn_lock_t *lock)
}
jobject
+CreateJ::ChangedPath(const char *path, svn_log_changed_path2_t *log_item)
+{
+ JNIEnv *env = JNIUtil::getEnv();
+
+ // Create a local frame for our references
+ env->PushLocalFrame(LOCAL_FRAME_SIZE);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
+
+ jclass clazzCP = env->FindClass(JAVA_PACKAGE"/ChangePath");
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+
+ static jmethodID midCP = 0;
+ if (midCP == 0)
+ {
+ midCP = env->GetMethodID(clazzCP,
+ "<init>",
+ "(Ljava/lang/String;JLjava/lang/String;"
+ "L"JAVA_PACKAGE"/ChangePath$Action;"
+ "L"JAVA_PACKAGE"/NodeKind;"
+ "L"JAVA_PACKAGE"/Tristate;"
+ "L"JAVA_PACKAGE"/Tristate;)V");
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(SVN_NO_ERROR);
+ }
+
+ jstring jpath = JNIUtil::makeJString(path);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jstring jcopyFromPath = JNIUtil::makeJString(log_item->copyfrom_path);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jobject jaction = EnumMapper::mapChangePathAction(log_item->action);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jobject jnodeKind = EnumMapper::mapNodeKind(log_item->node_kind);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jlong jcopyFromRev = log_item->copyfrom_rev;
+
+ jobject jcp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,
+ jcopyFromPath, jaction, jnodeKind,
+ EnumMapper::mapTristate(log_item->text_modified),
+ EnumMapper::mapTristate(log_item->props_modified));
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ return env->PopLocalFrame(jcp);
+}
+
+jobject
CreateJ::Status(svn_wc_context_t *wc_ctx, const char *local_abspath,
const svn_client_status_t *status, apr_pool_t *pool)
{
@@ -542,43 +599,58 @@ CreateJ::Status(svn_wc_context_t *wc_ctx
POP_AND_RETURN_NULL;
}
- const svn_wc_entry_t *entry = NULL;
-
- if (status->versioned)
+ if (status->versioned && status->conflicted)
{
- /* ### This call returns SVN_ERR_ENTRY_NOT_FOUND for all not found
- ### cases including the (for status) ignored
- ### SVN_ERR_NODE_UNEXPECTED_KIND!. Needs a workaround for 100%
- ### compatibility with <= 1.6 */
- svn_error_t *err = svn_wc__get_entry_versioned(&entry, wc_ctx, local_abspath,
- svn_node_unknown, FALSE, FALSE,
- pool, pool);
-
- if (err && err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
- svn_error_clear(err);
- else
- SVN_JNI_ERR(err, NULL);
- }
+ const char *conflict_new, *conflict_old, *conflict_wrk;
+ const char *copyfrom_url;
+ svn_revnum_t copyfrom_rev;
+ svn_boolean_t is_copy_target;
+
+ /* This call returns SVN_ERR_ENTRY_NOT_FOUND for some hidden
+ cases, which we can just ignore here as hidden nodes
+ are not in text or property conflict. */
+ svn_error_t *err = svn_wc__node_get_info_bits(NULL,
+ &conflict_old,
+ &conflict_new,
+ &conflict_wrk,
+ NULL,
+ wc_ctx, local_abspath,
+ pool, pool);
- if (entry != NULL)
- {
- jConflictNew = JNIUtil::makeJString(entry->conflict_new);
+ if (err)
+ {
+ if (err->apr_err == SVN_ERR_ENTRY_NOT_FOUND)
+ svn_error_clear(err);
+ else
+ SVN_JNI_ERR(err, NULL);
+ }
+
+ jConflictNew = JNIUtil::makeJString(conflict_new);
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jConflictOld = JNIUtil::makeJString(entry->conflict_old);
+ jConflictOld = JNIUtil::makeJString(conflict_old);
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jConflictWorking= JNIUtil::makeJString(entry->conflict_wrk);
+ jConflictWorking= JNIUtil::makeJString(conflict_wrk);
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jURLCopiedFrom = JNIUtil::makeJString(entry->copyfrom_url);
+ SVN_JNI_ERR(svn_wc__node_get_copyfrom_info(NULL, NULL,
+ ©from_url,
+ ©from_rev,
+ &is_copy_target,
+ wc_ctx, local_abspath,
+ pool, pool), NULL);
+
+ jURLCopiedFrom = JNIUtil::makeJString(is_copy_target ? copyfrom_url
+ : NULL);
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jRevisionCopiedFrom = entry->copyfrom_rev;
+ jRevisionCopiedFrom = is_copy_target ? copyfrom_rev
+ : SVN_INVALID_REVNUM;
}
}
@@ -779,6 +851,117 @@ CreateJ::ReposNotifyInformation(const sv
}
jobject
+CreateJ::CommitItem(svn_client_commit_item3_t *item)
+{
+ JNIEnv *env = JNIUtil::getEnv();
+
+ // Create a local frame for our references
+ env->PushLocalFrame(LOCAL_FRAME_SIZE);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
+
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitItem");
+ if (JNIUtil::isExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ // Get the method id for the CommitItem constructor.
+ static jmethodID midConstructor = 0;
+ if (midConstructor == 0)
+ {
+ midConstructor = env->GetMethodID(clazz, "<init>",
+ "(Ljava/lang/String;"
+ "L"JAVA_PACKAGE"/NodeKind;"
+ "ILjava/lang/String;"
+ "Ljava/lang/String;J)V");
+ if (JNIUtil::isExceptionThrown())
+ POP_AND_RETURN_NULL;
+ }
+
+ jstring jpath = JNIUtil::makeJString(item->path);
+
+ jobject jnodeKind = EnumMapper::mapNodeKind(item->kind);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jint jstateFlags = 0;
+ if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD)
+ jstateFlags |=
+ org_apache_subversion_javahl_CommitItemStateFlags_Add;
+ if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
+ jstateFlags |=
+ org_apache_subversion_javahl_CommitItemStateFlags_Delete;
+ if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_TEXT_MODS)
+ jstateFlags |=
+ org_apache_subversion_javahl_CommitItemStateFlags_TextMods;
+ if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_PROP_MODS)
+ jstateFlags |=
+ org_apache_subversion_javahl_CommitItemStateFlags_PropMods;
+ if (item->state_flags & SVN_CLIENT_COMMIT_ITEM_IS_COPY)
+ jstateFlags |=
+ org_apache_subversion_javahl_CommitItemStateFlags_IsCopy;
+
+ jstring jurl = JNIUtil::makeJString(item->url);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jstring jcopyUrl = JNIUtil::makeJString(item->copyfrom_url);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jlong jcopyRevision = item->revision;
+
+ // create the Java object
+ jobject jitem = env->NewObject(clazz, midConstructor, jpath,
+ jnodeKind, jstateFlags, jurl,
+ jcopyUrl, jcopyRevision);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ return env->PopLocalFrame(jitem);
+}
+
+jobject
+CreateJ::CommitInfo(const svn_commit_info_t *commit_info)
+{
+ JNIEnv *env = JNIUtil::getEnv();
+
+ // Create a local frame for our references
+ env->PushLocalFrame(LOCAL_FRAME_SIZE);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
+
+ static jmethodID midCT = 0;
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/CommitInfo");
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ if (midCT == 0)
+ {
+ midCT = env->GetMethodID(clazz, "<init>",
+ "(JLjava/lang/String;Ljava/lang/String;)V");
+ if (JNIUtil::isJavaExceptionThrown() || midCT == 0)
+ POP_AND_RETURN_NULL;
+ }
+
+ jstring jAuthor = JNIUtil::makeJString(commit_info->author);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jstring jDate = JNIUtil::makeJString(commit_info->date);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ jlong jRevision = commit_info->revision;
+
+ // call the Java method
+ jobject jInfo = env->NewObject(clazz, midCT, jRevision, jDate, jAuthor);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ return env->PopLocalFrame(jInfo);
+}
+
+jobject
CreateJ::RevisionRangeList(apr_array_header_t *ranges)
{
JNIEnv *env = JNIUtil::getEnv();
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/CreateJ.h Wed Sep 15 19:32:26 2010
@@ -52,6 +52,9 @@ class CreateJ
Lock(const svn_lock_t *lock);
static jobject
+ ChangedPath(const char *path, svn_log_changed_path2_t *log_item);
+
+ static jobject
Status(svn_wc_context_t *wc_ctx, const char *local_abspath,
const svn_client_status_t *status, apr_pool_t *pool);
@@ -62,6 +65,12 @@ class CreateJ
ReposNotifyInformation(const svn_repos_notify_t *notify, apr_pool_t *pool);
static jobject
+ CommitItem(svn_client_commit_item3_t *item);
+
+ static jobject
+ CommitInfo(const svn_commit_info_t *info);
+
+ static jobject
RevisionRangeList(apr_array_header_t *ranges);
static jobject
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.cpp Wed Sep 15 19:32:26 2010
@@ -58,6 +58,23 @@ jint EnumMapper::mapCommitMessageStateFl
return jstateFlags;
}
+jobject EnumMapper::mapChangePathAction(const char action)
+{
+ switch (action)
+ {
+ case 'A':
+ return mapEnum(JAVA_PACKAGE"/ChangePath$Action", 0);
+ case 'D':
+ return mapEnum(JAVA_PACKAGE"/ChangePath$Action", 1);
+ case 'R':
+ return mapEnum(JAVA_PACKAGE"/ChangePath$Action", 2);
+ case 'M':
+ return mapEnum(JAVA_PACKAGE"/ChangePath$Action", 3);
+ default:
+ return NULL;
+ }
+}
+
/**
* Map a C notify state constant to the Java constant.
*/
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/EnumMapper.h Wed Sep 15 19:32:26 2010
@@ -51,6 +51,7 @@ class EnumMapper
/* Converting from C enum's */
static jint mapCommitMessageStateFlags(apr_byte_t flags);
+ static jobject mapChangePathAction(const char action);
static jobject mapNotifyState(svn_wc_notify_state_t state);
static jobject mapNotifyAction(svn_wc_notify_action_t action);
static jobject mapReposNotifyNodeAction(svn_node_action action);
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/LogMessageCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/LogMessageCallback.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/LogMessageCallback.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/LogMessageCallback.cpp Wed Sep 15 19:32:26 2010
@@ -91,23 +91,6 @@ LogMessageCallback::singleMessage(svn_lo
POP_AND_RETURN(SVN_NO_ERROR);
}
- jclass clazzCP = env->FindClass(JAVA_PACKAGE"/ChangePath");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
-
- static jmethodID midCP = 0;
- if (midCP == 0)
- {
- midCP = env->GetMethodID(clazzCP,
- "<init>",
- "(Ljava/lang/String;JLjava/lang/String;C"
- "L"JAVA_PACKAGE"/NodeKind;"
- "L"JAVA_PACKAGE"/Tristate;"
- "L"JAVA_PACKAGE"/Tristate;)V");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
- }
-
jobject jChangedPaths = NULL;
if (log_entry->changed_paths)
{
@@ -122,33 +105,9 @@ LogMessageCallback::singleMessage(svn_lo
svn_log_changed_path2_t *log_item =
(svn_log_changed_path2_t *) svn__apr_hash_index_val(hi);
- jstring jpath = JNIUtil::makeJString(path);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
-
- jstring jcopyFromPath = JNIUtil::makeJString(log_item->copyfrom_path);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
-
- jobject jnodeKind = EnumMapper::mapNodeKind(log_item->node_kind);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
-
- jlong jcopyFromRev = log_item->copyfrom_rev;
- jchar jaction = log_item->action;
-
- jobject cp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,
- jcopyFromPath, jaction, jnodeKind,
- EnumMapper::mapTristate(log_item->text_modified),
- EnumMapper::mapTristate(log_item->props_modified));
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(SVN_NO_ERROR);
+ jobject cp = CreateJ::ChangedPath(path, log_item);
jcps.push_back(cp);
-
- env->DeleteLocalRef(jnodeKind);
- env->DeleteLocalRef(jpath);
- env->DeleteLocalRef(jcopyFromPath);
}
jChangedPaths = CreateJ::Set(jcps);
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/MessageReceiver.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/MessageReceiver.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/MessageReceiver.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/MessageReceiver.cpp Wed Sep 15 19:32:26 2010
@@ -58,7 +58,7 @@ void MessageReceiver::receiveMessage(con
static jmethodID mid = 0;
if (mid == 0)
{
- jclass clazz = env->FindClass(JAVA_PACKAGE"/SVNAdmin$MessageReceiver");
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/ISVNAdmin$MessageReceiver");
if (JNIUtil::isJavaExceptionThrown())
return;
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.cpp Wed Sep 15 19:32:26 2010
@@ -41,11 +41,9 @@
* @param v2 the callback objects implements PromptUserPassword2
* @param v3 the callback objects implements PromptUserPassword3
*/
-Prompter::Prompter(jobject jprompter, bool v2, bool v3)
+Prompter::Prompter(jobject jprompter)
{
m_prompter = jprompter;
- m_version2 = v2;
- m_version3 = v3;
}
Prompter::~Prompter()
@@ -79,35 +77,13 @@ Prompter *Prompter::makeCPrompter(jobjec
return NULL;
// Sanity check that the Java object implements PromptUserPassword.
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword");
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/callback/UserPasswordCallback");
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
if (!env->IsInstanceOf(jprompter, clazz))
POP_AND_RETURN_NULL;
- // Check if PromptUserPassword2 is implemented by the Java object.
- jclass clazz2 = env->FindClass(JAVA_PACKAGE"/PromptUserPassword2");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
-
- bool v2 = env->IsInstanceOf(jprompter, clazz2) ? true: false;
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
-
- bool v3 = false;
- if (v2)
- {
- // Check if PromptUserPassword3 is implemented by the Java object.
- jclass clazz3 = env->FindClass(JAVA_PACKAGE"/PromptUserPassword3");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
-
- v3 = env->IsInstanceOf(jprompter, clazz3) ? true: false;
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
- }
-
// Create a new global ref for the Java object, because it is
// longer used that this call.
jobject myPrompt = env->NewGlobalRef(jprompter);
@@ -117,7 +93,7 @@ Prompter *Prompter::makeCPrompter(jobjec
env->PopLocalFrame(NULL);
// Create the C++ peer.
- return new Prompter(myPrompt, v2, v3);
+ return new Prompter(myPrompt);
}
/**
@@ -251,101 +227,53 @@ const char *Prompter::askQuestion(const
if (JNIUtil::isJavaExceptionThrown())
return false;
- if (m_version3)
+ static jmethodID mid = 0;
+ static jmethodID mid2 = 0;
+ if (mid == 0)
{
- static jmethodID mid = 0;
- static jmethodID mid2 = 0;
- if (mid == 0)
- {
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword3");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
-
- mid = env->GetMethodID(clazz, "askQuestion",
- "(Ljava/lang/String;Ljava/lang/String;"
- "ZZ)Ljava/lang/String;");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN_NULL;
-
- mid2 = env->GetMethodID(clazz, "userAllowedSave", "()Z");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN_NULL;
- }
-
- jstring jrealm = JNIUtil::makeJString(realm);
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword3");
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
- jstring jquestion = JNIUtil::makeJString(question);
- if (JNIUtil::isJavaExceptionThrown())
+ mid = env->GetMethodID(clazz, "askQuestion",
+ "(Ljava/lang/String;Ljava/lang/String;"
+ "ZZ)Ljava/lang/String;");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
POP_AND_RETURN_NULL;
- jstring janswer = static_cast<jstring>(
- env->CallObjectMethod(m_prompter, mid, jrealm,
- jquestion,
- showAnswer ? JNI_TRUE : JNI_FALSE,
- maySave ? JNI_TRUE : JNI_FALSE));
- if (JNIUtil::isJavaExceptionThrown())
+ mid2 = env->GetMethodID(clazz, "userAllowedSave", "()Z");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
POP_AND_RETURN_NULL;
-
- JNIStringHolder answer(janswer);
- if (answer != NULL)
- {
- m_answer = answer;
- m_maySave = env->CallBooleanMethod(m_prompter, mid2) ? true: false;
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
- }
- else
- {
- m_answer = "";
- m_maySave = false;
- }
}
- else
- {
- static jmethodID mid = 0;
- if (mid == 0)
- {
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
-
- mid = env->GetMethodID(clazz, "askQuestion",
- "(Ljava/lang/String;Ljava/lang/String;Z)"
- "Ljava/lang/String;");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN_NULL;
- }
- jstring jrealm = JNIUtil::makeJString(realm);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
+ jstring jrealm = JNIUtil::makeJString(realm);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
- jstring jquestion = JNIUtil::makeJString(question);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN_NULL;
+ jstring jquestion = JNIUtil::makeJString(question);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
- jstring janswer = static_cast<jstring>(
- env->CallObjectMethod(m_prompter, mid, jrealm,
- jquestion, showAnswer ? JNI_TRUE : JNI_FALSE));
+ jstring janswer = static_cast<jstring>(
+ env->CallObjectMethod(m_prompter, mid, jrealm,
+ jquestion,
+ showAnswer ? JNI_TRUE : JNI_FALSE,
+ maySave ? JNI_TRUE : JNI_FALSE));
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN_NULL;
+
+ JNIStringHolder answer(janswer);
+ if (answer != NULL)
+ {
+ m_answer = answer;
+ m_maySave = env->CallBooleanMethod(m_prompter, mid2) ? true: false;
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN_NULL;
-
- JNIStringHolder answer(janswer);
- if (answer != NULL)
- {
- m_answer = answer;
- if (maySave)
- m_maySave = askYesNo(realm, _("May save the answer ?"), true);
- else
- m_maySave = false;
- }
- else
- {
- m_answer = "";
- m_maySave = false;
- }
+ }
+ else
+ {
+ m_answer = "";
+ m_maySave = false;
}
env->PopLocalFrame(NULL);
@@ -354,58 +282,36 @@ const char *Prompter::askQuestion(const
int Prompter::askTrust(const char *question, bool maySave)
{
- if (m_version2)
- {
- static jmethodID mid = 0;
- JNIEnv *env = JNIUtil::getEnv();
-
- // Create a local frame for our references
- env->PushLocalFrame(LOCAL_FRAME_SIZE);
- if (JNIUtil::isJavaExceptionThrown())
- return -1;
-
- if (mid == 0)
- {
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword2");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(-1);
-
- mid = env->GetMethodID(clazz, "askTrustSSLServer",
- "(Ljava/lang/String;Z)I");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN(-1);
- }
- jstring jquestion = JNIUtil::makeJString(question);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(-1);
+ static jmethodID mid = 0;
+ JNIEnv *env = JNIUtil::getEnv();
- jint ret = env->CallIntMethod(m_prompter, mid, jquestion,
- maySave ? JNI_TRUE : JNI_FALSE);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(-1);
+ // Create a local frame for our references
+ env->PushLocalFrame(LOCAL_FRAME_SIZE);
+ if (JNIUtil::isJavaExceptionThrown())
+ return -1;
+
+ if (mid == 0)
+ {
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword2");
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(-1);
+
+ mid = env->GetMethodID(clazz, "askTrustSSLServer",
+ "(Ljava/lang/String;Z)I");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
+ POP_AND_RETURN(-1);
+ }
+ jstring jquestion = JNIUtil::makeJString(question);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(-1);
+
+ jint ret = env->CallIntMethod(m_prompter, mid, jquestion,
+ maySave ? JNI_TRUE : JNI_FALSE);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(-1);
- env->PopLocalFrame(NULL);
- return ret;
- }
- else
- {
- std::string q = question;
- if (maySave)
- q += _("(R)eject, accept (t)emporarily or accept (p)ermanently?");
- else
- q += _("(R)eject or accept (t)emporarily?");
-
- const char *answer = askQuestion(NULL, q.c_str(), true, false);
- if (*answer == 't' || *answer == 'T')
- return
- org_apache_subversion_javahl_callback_UserPasswordCallback_AcceptTemporary;
- else if (maySave && (*answer == 'p' || *answer == 'P'))
- return
- org_apache_subversion_javahl_callback_UserPasswordCallback_AcceptPermanently;
- else
- return org_apache_subversion_javahl_callback_UserPasswordCallback_Reject;
- }
- return -1;
+ env->PopLocalFrame(NULL);
+ return ret;
}
bool Prompter::prompt(const char *realm, const char *pi_username, bool maySave)
@@ -418,75 +324,40 @@ bool Prompter::prompt(const char *realm,
if (JNIUtil::isJavaExceptionThrown())
return false;
- if (m_version3)
+ static jmethodID mid = 0;
+ static jmethodID mid2 = 0;
+ if (mid == 0)
{
- static jmethodID mid = 0;
- static jmethodID mid2 = 0;
- if (mid == 0)
- {
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword3");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
-
- mid = env->GetMethodID(clazz, "prompt",
- "(Ljava/lang/String;Ljava/lang/String;Z)Z");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN(false);
-
- mid2 = env->GetMethodID(clazz, "userAllowedSave", "()Z");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN(false);
- }
-
- jstring jrealm = JNIUtil::makeJString(realm);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
-
- jstring jusername = JNIUtil::makeJString(pi_username);
+ jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword3");
if (JNIUtil::isJavaExceptionThrown())
POP_AND_RETURN(false);
- ret = env->CallBooleanMethod(m_prompter, mid, jrealm, jusername,
- maySave ? JNI_TRUE: JNI_FALSE);
- if (JNIUtil::isJavaExceptionThrown())
+ mid = env->GetMethodID(clazz, "prompt",
+ "(Ljava/lang/String;Ljava/lang/String;Z)Z");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
POP_AND_RETURN(false);
- m_maySave = env->CallBooleanMethod(m_prompter, mid2) ? true : false;
- if (JNIUtil::isJavaExceptionThrown())
+ mid2 = env->GetMethodID(clazz, "userAllowedSave", "()Z");
+ if (JNIUtil::isJavaExceptionThrown() || mid == 0)
POP_AND_RETURN(false);
}
- else
- {
- static jmethodID mid = 0;
- if (mid == 0)
- {
- jclass clazz = env->FindClass(JAVA_PACKAGE"/PromptUserPassword");
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
-
- mid = env->GetMethodID(clazz, "prompt",
- "(Ljava/lang/String;Ljava/lang/String;)Z");
- if (JNIUtil::isJavaExceptionThrown() || mid == 0)
- POP_AND_RETURN(false);
- }
- jstring jrealm = JNIUtil::makeJString(realm);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
+ jstring jrealm = JNIUtil::makeJString(realm);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(false);
- jstring jusername = JNIUtil::makeJString(pi_username);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
+ jstring jusername = JNIUtil::makeJString(pi_username);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(false);
- ret = env->CallBooleanMethod(m_prompter, mid, jrealm, jusername);
- if (JNIUtil::isJavaExceptionThrown())
- POP_AND_RETURN(false);
+ ret = env->CallBooleanMethod(m_prompter, mid, jrealm, jusername,
+ maySave ? JNI_TRUE: JNI_FALSE);
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(false);
- if (maySave)
- m_maySave = askYesNo(realm, _("May save the answer ?"), true);
- else
- m_maySave = false;
- }
+ m_maySave = env->CallBooleanMethod(m_prompter, mid2) ? true : false;
+ if (JNIUtil::isJavaExceptionThrown())
+ POP_AND_RETURN(false);
env->PopLocalFrame(NULL);
return ret ? true:false;
@@ -717,3 +588,37 @@ Prompter::ssl_client_cert_pw_prompt(svn_
*cred_p = ret;
return SVN_NO_ERROR;
}
+
+svn_error_t *
+Prompter::plaintext_prompt(svn_boolean_t *may_save_plaintext,
+ const char *realmstring,
+ void *baton,
+ apr_pool_t *pool)
+{
+ Prompter *that = (Prompter *) baton;
+
+ bool result = that->askYesNo(realmstring,
+ _("Store password unencrypted?"),
+ false);
+
+ *may_save_plaintext = (result ? TRUE : FALSE);
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+Prompter::plaintext_passphrase_prompt(svn_boolean_t *may_save_plaintext,
+ const char *realmstring,
+ void *baton,
+ apr_pool_t *pool)
+{
+ Prompter *that = (Prompter *) baton;
+
+ bool result = that->askYesNo(realmstring,
+ _("Store passphrase unencrypted?"),
+ false);
+
+ *may_save_plaintext = (result ? TRUE : FALSE);
+
+ return SVN_NO_ERROR;
+}
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/Prompter.h Wed Sep 15 19:32:26 2010
@@ -46,16 +46,6 @@ class Prompter
jobject m_prompter;
/**
- * The callback objects implements PromptUserPassword2.
- */
- bool m_version2;
-
- /**
- * The callback objects implements PromptUserPassword3.
- */
- bool m_version3;
-
- /**
* Tntermediate storage for an answer.
*/
std::string m_answer;
@@ -66,7 +56,7 @@ class Prompter
*/
bool m_maySave;
- Prompter(jobject jprompter, bool v2, bool v3);
+ Prompter(jobject jprompter);
bool prompt(const char *realm, const char *pi_username, bool maySave);
bool askYesNo(const char *realm, const char *question, bool yesIsDefault);
const char *askQuestion(const char *realm, const char *question,
@@ -113,6 +103,16 @@ class Prompter
svn_auth_provider_object_t *getProviderServerSSLTrust();
svn_auth_provider_object_t *getProviderClientSSL();
svn_auth_provider_object_t *getProviderClientSSLPassword();
+
+ static svn_error_t *plaintext_prompt(svn_boolean_t *may_save_plaintext,
+ const char *realmstring,
+ void *baton,
+ apr_pool_t *pool);
+ static svn_error_t *plaintext_passphrase_prompt(
+ svn_boolean_t *may_save_plaintext,
+ const char *realmstring,
+ void *baton,
+ apr_pool_t *pool);
};
#endif // PROMPTER_H
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.cpp Wed Sep 15 19:32:26 2010
@@ -29,6 +29,7 @@
SVNBase::SVNBase()
{
+ jthis = NULL;
}
SVNBase::~SVNBase()
@@ -44,6 +45,7 @@ jlong SVNBase::findCppAddrForJObject(job
const char *className)
{
JNIEnv *env = JNIUtil::getEnv();
+
findCppAddrFieldID(fid, className, env);
if (*fid == 0)
{
@@ -52,7 +54,18 @@ jlong SVNBase::findCppAddrForJObject(job
else
{
jlong cppAddr = env->GetLongField(jthis, *fid);
- return (JNIUtil::isJavaExceptionThrown() ? 0 : cppAddr);
+ if (JNIUtil::isJavaExceptionThrown())
+ return 0;
+
+ /* jthis is not guaranteed to be the same between JNI invocations, so
+ we do a little dance here and store the updated version in our
+ object for this invocation.
+
+ findCppAddrForJObject() is, by necessity, called before any other
+ methods on the C++ object, so by doing this we can guarantee a valid
+ jthis pointer for subsequent uses. */
+ (reinterpret_cast<SVNBase *> (cppAddr))->jthis = jthis;
+ return cppAddr;
}
}
@@ -65,15 +78,17 @@ void SVNBase::finalize()
JNIUtil::enqueueForDeletion(this);
}
-void SVNBase::dispose(jobject jthis, jfieldID *fid, const char *className)
+void SVNBase::dispose(jfieldID *fid, const char *className)
{
+ jobject my_jthis = this->jthis;
+
delete this;
JNIEnv *env = JNIUtil::getEnv();
SVNBase::findCppAddrFieldID(fid, className, env);
if (*fid == 0)
return;
- env->SetLongField(jthis, *fid, 0);
+ env->SetLongField(my_jthis, *fid, 0);
if (JNIUtil::isJavaExceptionThrown())
return;
}
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNBase.h Wed Sep 15 19:32:26 2010
@@ -48,7 +48,7 @@ class SVNBase
*
* @since 1.4.0
*/
- virtual void dispose(jobject jthis) = 0;
+ virtual void dispose() = 0;
/**
* This method should never be called, as @c dispose() should be
@@ -79,7 +79,13 @@ class SVNBase
*
* @since 1.4.0
*/
- void dispose(jobject jthis, jfieldID *fid, const char *className);
+ void dispose(jfieldID *fid, const char *className);
+
+ /**
+ * A pointer to the parent java object. This is not valid across JNI
+ * method invocations, and so should be set in each one.
+ */
+ jobject jthis;
private:
/**
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.cpp?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.cpp Wed Sep 15 19:32:26 2010
@@ -26,11 +26,9 @@
#include "SVNClient.h"
#include "JNIUtil.h"
-#include "ClientNotifyCallback.h"
#include "CopySources.h"
#include "DiffSummaryReceiver.h"
-#include "ConflictResolverCallback.h"
-#include "ProgressListener.h"
+#include "ClientContext.h"
#include "Prompter.h"
#include "Pool.h"
#include "Targets.h"
@@ -41,6 +39,7 @@
#include "LogMessageCallback.h"
#include "InfoCallback.h"
#include "PatchCallback.h"
+#include "CommitCallback.h"
#include "StatusCallback.h"
#include "ChangelistCallback.h"
#include "ListCallback.h"
@@ -68,27 +67,14 @@
#include <iostream>
#include <sstream>
-struct log_msg_baton
-{
- const char *message;
- CommitMessage *messageHandler;
-};
-SVNClient::SVNClient()
+SVNClient::SVNClient(jobject jthis_in)
+ : context(jthis_in)
{
- m_notify2 = NULL;
- m_progressListener = NULL;
- m_prompter = NULL;
- m_commitMessage = NULL;
- m_conflictResolver = NULL;
}
SVNClient::~SVNClient()
{
- delete m_notify2;
- delete m_progressListener;
- delete m_prompter;
- delete m_conflictResolver;
}
SVNClient *SVNClient::getCppObject(jobject jthis)
@@ -99,10 +85,10 @@ SVNClient *SVNClient::getCppObject(jobje
return (cppAddr == 0 ? NULL : reinterpret_cast<SVNClient *>(cppAddr));
}
-void SVNClient::dispose(jobject jthis)
+void SVNClient::dispose()
{
static jfieldID fid = 0;
- SVNBase::dispose(jthis, &fid, JAVA_PACKAGE"/SVNClient");
+ SVNBase::dispose(&fid, JAVA_PACKAGE"/SVNClient");
}
jstring SVNClient::getAdminDirectoryName()
@@ -136,7 +122,7 @@ void SVNClient::list(const char *url, Re
ListCallback *callback)
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -168,7 +154,7 @@ SVNClient::status(const char *path, svn_
SVN_JNI_NULL_PTR_EX(path, "path", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
callback->setWcCtx(ctx->wc_ctx);
@@ -181,29 +167,13 @@ SVNClient::status(const char *path, svn_
SVN_JNI_ERR(svn_client_status5(&youngest, ctx, checkedPath.c_str(),
&rev,
depth,
- getAll, onServer, noIgnore,
+ getAll, onServer, noIgnore, FALSE,
ignoreExternals,
changelists.array(requestPool),
StatusCallback::callback, callback,
requestPool.pool()), );
}
-void SVNClient::username(const char *pi_username)
-{
- m_userName = (pi_username == NULL ? "" : pi_username);
-}
-
-void SVNClient::password(const char *pi_password)
-{
- m_passWord = (pi_password == NULL ? "" : pi_password);
-}
-
-void SVNClient::setPrompt(Prompter *prompter)
-{
- delete m_prompter;
- m_prompter = prompter;
-}
-
void SVNClient::logMessages(const char *path, Revision &pegRevision,
std::vector<RevisionRange> &logRanges,
bool stopOnCopy, bool discoverPaths,
@@ -214,7 +184,7 @@ void SVNClient::logMessages(const char *
SVN_JNI_NULL_PTR_EX(path, "path", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -275,7 +245,7 @@ jlong SVNClient::checkout(const char *mo
SVN_JNI_ERR(path.error_occured(), -1);
svn_revnum_t rev;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return -1;
@@ -293,39 +263,22 @@ jlong SVNClient::checkout(const char *mo
return rev;
}
-void SVNClient::notification2(ClientNotifyCallback *notify2)
-{
- delete m_notify2;
- m_notify2 = notify2;
-}
-
-void SVNClient::setConflictResolver(ConflictResolverCallback *conflictResolver)
-{
- delete m_conflictResolver;
- m_conflictResolver = conflictResolver;
-}
-
-void SVNClient::setProgressListener(ProgressListener *listener)
-{
- delete m_progressListener;
- m_progressListener = listener;
-}
-
-void SVNClient::remove(Targets &targets, const char *message, bool force,
- bool keep_local, RevpropTable &revprops)
+void SVNClient::remove(Targets &targets, CommitMessage *message, bool force,
+ bool keep_local, RevpropTable &revprops,
+ CommitCallback *callback)
{
- svn_commit_info_t *commit_info = NULL;
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(message);
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
return;
const apr_array_header_t *targets2 = targets.array(requestPool);
SVN_JNI_ERR(targets.error_occured(), );
- SVN_JNI_ERR(svn_client_delete3(&commit_info, targets2, force, keep_local,
- revprops.hash(requestPool), ctx,
- requestPool.pool()), );
+ SVN_JNI_ERR(svn_client_delete4(targets2, force, keep_local,
+ revprops.hash(requestPool),
+ CommitCallback::callback, callback,
+ ctx, requestPool.pool()), );
}
void SVNClient::revert(const char *path, svn_depth_t depth,
@@ -335,7 +288,7 @@ void SVNClient::revert(const char *path,
SVN_JNI_NULL_PTR_EX(path, "path", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -357,7 +310,7 @@ void SVNClient::add(const char *path,
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -373,7 +326,7 @@ jlongArray SVNClient::update(Targets &ta
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
apr_array_header_t *revs;
if (ctx == NULL)
return NULL;
@@ -406,34 +359,31 @@ jlongArray SVNClient::update(Targets &ta
return jrevs;
}
-jlong SVNClient::commit(Targets &targets, const char *message,
- svn_depth_t depth, bool noUnlock, bool keepChangelist,
- StringArray &changelists, RevpropTable &revprops)
+void SVNClient::commit(Targets &targets, CommitMessage *message,
+ svn_depth_t depth, bool noUnlock, bool keepChangelist,
+ StringArray &changelists, RevpropTable &revprops,
+ CommitCallback *callback)
{
SVN::Pool requestPool;
- svn_commit_info_t *commit_info = NULL;
const apr_array_header_t *targets2 = targets.array(requestPool);
- SVN_JNI_ERR(targets.error_occured(), -1);
- svn_client_ctx_t *ctx = getContext(message);
+ SVN_JNI_ERR(targets.error_occured(), );
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
- return SVN_INVALID_REVNUM;
+ return;
- SVN_JNI_ERR(svn_client_commit4(&commit_info, targets2, depth,
+ SVN_JNI_ERR(svn_client_commit5(targets2, depth,
noUnlock, keepChangelist,
changelists.array(requestPool),
- revprops.hash(requestPool), ctx,
- requestPool.pool()),
- SVN_INVALID_REVNUM);
-
- if (commit_info && SVN_IS_VALID_REVNUM(commit_info->revision))
- return commit_info->revision;
-
- return SVN_INVALID_REVNUM;
+ revprops.hash(requestPool),
+ CommitCallback::callback, callback,
+ ctx, requestPool.pool()),
+ );
}
void SVNClient::copy(CopySources ©Sources, const char *destPath,
- const char *message, bool copyAsChild, bool makeParents,
- bool ignoreExternals, RevpropTable &revprops)
+ CommitMessage *message, bool copyAsChild,
+ bool makeParents, bool ignoreExternals,
+ RevpropTable &revprops, CommitCallback *callback)
{
SVN::Pool requestPool;
@@ -448,20 +398,21 @@ void SVNClient::copy(CopySources ©So
Path destinationPath(destPath);
SVN_JNI_ERR(destinationPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(message);
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
return;
- svn_commit_info_t *commit_info;
- SVN_JNI_ERR(svn_client_copy5(&commit_info, srcs, destinationPath.c_str(),
+ SVN_JNI_ERR(svn_client_copy6(srcs, destinationPath.c_str(),
copyAsChild, makeParents, ignoreExternals,
- revprops.hash(requestPool), ctx,
- requestPool.pool()), );
+ revprops.hash(requestPool),
+ CommitCallback::callback, callback,
+ ctx, requestPool.pool()), );
}
void SVNClient::move(Targets &srcPaths, const char *destPath,
- const char *message, bool force, bool moveAsChild,
- bool makeParents, RevpropTable &revprops)
+ CommitMessage *message, bool force, bool moveAsChild,
+ bool makeParents, RevpropTable &revprops,
+ CommitCallback *callback)
{
SVN::Pool requestPool;
@@ -471,32 +422,33 @@ void SVNClient::move(Targets &srcPaths,
Path destinationPath(destPath);
SVN_JNI_ERR(destinationPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(message);
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
return;
- svn_commit_info_t *commit_info;
- SVN_JNI_ERR(svn_client_move5(&commit_info, (apr_array_header_t *) srcs,
+ SVN_JNI_ERR(svn_client_move6((apr_array_header_t *) srcs,
destinationPath.c_str(), force, moveAsChild,
- makeParents, revprops.hash(requestPool), ctx,
+ makeParents, revprops.hash(requestPool),
+ CommitCallback::callback, callback, ctx,
requestPool.pool()), );
}
-void SVNClient::mkdir(Targets &targets, const char *message, bool makeParents,
- RevpropTable &revprops)
+void SVNClient::mkdir(Targets &targets, CommitMessage *message,
+ bool makeParents, RevpropTable &revprops,
+ CommitCallback *callback)
{
SVN::Pool requestPool;
- svn_commit_info_t *commit_info = NULL;
- svn_client_ctx_t *ctx = getContext(message);
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
return;
const apr_array_header_t *targets2 = targets.array(requestPool);
SVN_JNI_ERR(targets.error_occured(), );
- SVN_JNI_ERR(svn_client_mkdir3(&commit_info, targets2, makeParents,
- revprops.hash(requestPool), ctx,
- requestPool.pool()), );
+ SVN_JNI_ERR(svn_client_mkdir4(targets2, makeParents,
+ revprops.hash(requestPool),
+ CommitCallback::callback, callback,
+ ctx, requestPool.pool()), );
}
void SVNClient::cleanup(const char *path)
@@ -506,7 +458,7 @@ void SVNClient::cleanup(const char *path
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -520,7 +472,7 @@ void SVNClient::resolve(const char *path
SVN_JNI_NULL_PTR_EX(path, "path", );
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -541,7 +493,7 @@ jlong SVNClient::doExport(const char *sr
Path destinationPath(destPath);
SVN_JNI_ERR(destinationPath.error_occured(), -1);
svn_revnum_t rev;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return -1;
@@ -574,7 +526,7 @@ jlong SVNClient::doSwitch(const char *pa
SVN_JNI_ERR(intPath.error_occured(), -1);
svn_revnum_t rev;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return -1;
@@ -594,9 +546,9 @@ jlong SVNClient::doSwitch(const char *pa
}
void SVNClient::doImport(const char *path, const char *url,
- const char *message, svn_depth_t depth,
+ CommitMessage *message, svn_depth_t depth,
bool noIgnore, bool ignoreUnknownNodeTypes,
- RevpropTable &revprops)
+ RevpropTable &revprops, CommitCallback *callback)
{
SVN::Pool requestPool;
SVN_JNI_NULL_PTR_EX(path, "path", );
@@ -606,23 +558,22 @@ void SVNClient::doImport(const char *pat
Path intUrl(url);
SVN_JNI_ERR(intUrl.error_occured(), );
- svn_commit_info_t *commit_info = NULL;
- svn_client_ctx_t *ctx = getContext(message);
+ svn_client_ctx_t *ctx = context.getContext(message);
if (ctx == NULL)
return;
- SVN_JNI_ERR(svn_client_import3(&commit_info, intPath.c_str(),
- intUrl.c_str(), depth, noIgnore,
- ignoreUnknownNodeTypes,
- revprops.hash(requestPool), ctx,
- requestPool.pool()), );
+ SVN_JNI_ERR(svn_client_import4(intPath.c_str(), intUrl.c_str(), depth,
+ noIgnore, ignoreUnknownNodeTypes,
+ revprops.hash(requestPool),
+ CommitCallback::callback, callback,
+ ctx, requestPool.pool()), );
}
jobject
SVNClient::suggestMergeSources(const char *path, Revision &pegRevision)
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
@@ -653,7 +604,7 @@ void SVNClient::merge(const char *path1,
Path srcPath2 = path2;
SVN_JNI_ERR(srcPath2.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -679,7 +630,7 @@ void SVNClient::merge(const char *path,
Path srcPath(path);
SVN_JNI_ERR(srcPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -734,7 +685,7 @@ void SVNClient::mergeReintegrate(const c
Path srcPath(path);
SVN_JNI_ERR(srcPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -751,7 +702,7 @@ SVNClient::getMergeinfo(const char *targ
SVN::Pool requestPool;
JNIEnv *env = JNIUtil::getEnv();
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
@@ -828,7 +779,7 @@ void SVNClient::getMergeinfoLog(int type
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -868,7 +819,7 @@ jbyteArray SVNClient::propertyGet(const
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), NULL);
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
@@ -904,7 +855,7 @@ void SVNClient::properties(const char *p
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -920,7 +871,7 @@ void SVNClient::properties(const char *p
void SVNClient::propertySet(const char *path, const char *name,
const char *value, svn_depth_t depth,
StringArray &changelists, bool force,
- RevpropTable &revprops)
+ RevpropTable &revprops, CommitCallback *callback)
{
SVN::Pool requestPool;
SVN_JNI_NULL_PTR_EX(path, "path", );
@@ -932,18 +883,18 @@ void SVNClient::propertySet(const char *
else
val = svn_string_create(value, requestPool.pool());
- svn_commit_info_t *commit_info = NULL;
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
- SVN_JNI_ERR(svn_client_propset3(&commit_info, name, val, intPath.c_str(),
+ SVN_JNI_ERR(svn_client_propset4(name, val, intPath.c_str(),
depth, force, SVN_INVALID_REVNUM,
changelists.array(requestPool),
revprops.hash(requestPool),
+ CommitCallback::callback, callback,
ctx, requestPool.pool()), );
}
@@ -967,7 +918,7 @@ void SVNClient::diff(const char *target1
SVN_JNI_NULL_PTR_EX(target2, "target2", );
SVN_JNI_NULL_PTR_EX(outfileName, "outfileName", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1004,6 +955,7 @@ void SVNClient::diff(const char *target1
noDiffDelete,
showCopiesAsAdds,
force,
+ FALSE,
SVN_APR_LOCALE_CHARSET,
outfile,
NULL /* error file */,
@@ -1035,6 +987,7 @@ void SVNClient::diff(const char *target1
noDiffDelete,
showCopiesAsAdds,
force,
+ FALSE,
SVN_APR_LOCALE_CHARSET,
outfile,
NULL /* error file */,
@@ -1092,7 +1045,7 @@ SVNClient::diffSummarize(const char *tar
SVN_JNI_NULL_PTR_EX(target1, "target1", );
SVN_JNI_NULL_PTR_EX(target2, "target2", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1121,7 +1074,7 @@ SVNClient::diffSummarize(const char *tar
SVN_JNI_NULL_PTR_EX(target, "target", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1140,158 +1093,6 @@ SVNClient::diffSummarize(const char *tar
requestPool.pool()), );
}
-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_JNI_ERR(svn_client_create_context(&ctx, pool), NULL);
-
- const char *configDir = m_configDir.c_str();
- if (m_configDir.length() == 0)
- configDir = NULL;
- SVN_JNI_ERR(svn_config_get_config(&(ctx->config), configDir, pool), NULL);
- svn_config_t *config = (svn_config_t *) apr_hash_get(ctx->config,
- SVN_CONFIG_CATEGORY_CONFIG,
- APR_HASH_KEY_STRING);
-
- /* The whole list of registered providers */
- apr_array_header_t *providers;
-
- /* Populate the registered providers with the platform-specific providers */
- SVN_JNI_ERR(svn_auth_get_platform_specific_client_providers(&providers,
- config,
- pool),
- NULL);
-
- /* The main disk-caching auth providers, for both
- * 'username/password' creds and 'username' creds. */
- svn_auth_provider_object_t *provider;
-
- svn_auth_get_simple_provider(&provider, pool);
- APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
- svn_auth_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_JNI_ERR(svn_auth_get_platform_specific_provider(&provider,
- "windows",
- "ssl_server_trust",
- pool),
- NULL);
-
- if (provider)
- APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
-
- svn_auth_get_ssl_server_trust_file_provider(&provider, pool);
- APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
- svn_auth_get_ssl_client_cert_file_provider(&provider, pool);
- APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
- svn_auth_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 = NULL;
- ctx->notify_baton = NULL;
- ctx->log_msg_func3 = getCommitMessage;
- ctx->log_msg_baton3 = getCommitMessageBaton(message);
- ctx->cancel_func = checkCancel;
- m_cancelOperation = false;
- ctx->cancel_baton = this;
- ctx->notify_func2= ClientNotifyCallback::notify;
- ctx->notify_baton2 = m_notify2;
-
- ctx->progress_func = ProgressListener::progress;
- ctx->progress_baton = m_progressListener;
-
- if (m_conflictResolver)
- {
- ctx->conflict_func = ConflictResolverCallback::resolveConflict;
- ctx->conflict_baton = m_conflictResolver;
- }
-
- return ctx;
-}
-
-svn_error_t *
-SVNClient::getCommitMessage(const char **log_msg,
- const char **tmp_file,
- const 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;
-}
-
jbyteArray SVNClient::fileContent(const char *path, Revision &revision,
Revision &pegRevision)
{
@@ -1418,7 +1219,7 @@ svn_stream_t *SVNClient::createReadStrea
}
else
{
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
@@ -1442,7 +1243,7 @@ jbyteArray SVNClient::revProperty(const
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), NULL);
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
@@ -1487,7 +1288,7 @@ void SVNClient::relocate(const char *fro
Path intTo(to);
SVN_JNI_ERR(intTo.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1507,7 +1308,7 @@ void SVNClient::blame(const char *path,
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1521,47 +1322,11 @@ void SVNClient::blame(const char *path,
);
}
-void SVNClient::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.pool()), );
-
- m_configDir = (configDir == NULL ? "" : configDir);
-}
-
-const char *SVNClient::getConfigDirectory()
-{
- return m_configDir.c_str();
-}
-
-void SVNClient::commitMessageHandler(CommitMessage *commitMessage)
-{
- delete m_commitMessage;
- m_commitMessage = commitMessage;
-}
-
-void SVNClient::cancelOperation()
-{
- m_cancelOperation = true;
-}
-
-svn_error_t *SVNClient::checkCancel(void *cancelBaton)
-{
- SVNClient *that = (SVNClient*)cancelBaton;
- if (that->m_cancelOperation)
- return svn_error_create(SVN_ERR_CANCELLED, NULL,
- _("Operation canceled"));
- else
- return SVN_NO_ERROR;
-}
-
void SVNClient::addToChangelist(Targets &srcPaths, const char *changelist,
svn_depth_t depth, StringArray &changelists)
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
const apr_array_header_t *srcs = srcPaths.array(requestPool);
SVN_JNI_ERR(srcPaths.error_occured(), );
@@ -1575,7 +1340,7 @@ void SVNClient::removeFromChangelists(Ta
StringArray &changelists)
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
const apr_array_header_t *srcs = srcPaths.array(requestPool);
SVN_JNI_ERR(srcPaths.error_occured(), );
@@ -1591,7 +1356,7 @@ void SVNClient::getChangelists(const cha
ChangelistCallback *callback)
{
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
SVN_JNI_ERR(svn_client_get_changelists(rootPath,
changelists.array(requestPool),
@@ -1605,7 +1370,7 @@ void SVNClient::lock(Targets &targets, c
SVN::Pool requestPool;
const apr_array_header_t *targetsApr = targets.array(requestPool);
SVN_JNI_ERR(targets.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
SVN_JNI_ERR(svn_client_lock(targetsApr, comment, force, ctx,
requestPool.pool()), );
@@ -1617,7 +1382,7 @@ void SVNClient::unlock(Targets &targets,
const apr_array_header_t *targetsApr = targets.array(requestPool);
SVN_JNI_ERR(targets.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
SVN_JNI_ERR(svn_client_unlock((apr_array_header_t*)targetsApr, force,
ctx, requestPool.pool()), );
}
@@ -1632,7 +1397,7 @@ void SVNClient::setRevProperty(const cha
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1671,7 +1436,7 @@ jstring SVNClient::getVersionInfo(const
SVN_JNI_ERR(intPath.error_occured(), NULL);
int wc_format;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return NULL;
SVN_JNI_ERR(svn_wc_check_wc2(&wc_format, ctx->wc_ctx, intPath.c_str(),
@@ -1730,7 +1495,7 @@ void SVNClient::upgrade(const char *path
SVN::Pool requestPool;
SVN_JNI_NULL_PTR_EX(path, "path", );
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1748,7 +1513,7 @@ jobject SVNClient::revProperties(const c
Path intPath(path);
SVN_JNI_ERR(intPath.error_occured(), NULL);
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
const char *URL;
svn_revnum_t set_rev;
SVN_JNI_ERR(svn_client_url_from_path2(&URL, intPath.c_str(), ctx,
@@ -1781,7 +1546,7 @@ SVNClient::info2(const char *path, Revis
SVN_JNI_NULL_PTR_EX(path, "path", );
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1806,7 +1571,7 @@ SVNClient::patch(const char *patchPath,
SVN_JNI_NULL_PTR_EX(targetPath, "targetPath", );
SVN::Pool requestPool;
- svn_client_ctx_t *ctx = getContext(NULL);
+ svn_client_ctx_t *ctx = context.getContext(NULL);
if (ctx == NULL)
return;
@@ -1815,11 +1580,18 @@ SVNClient::patch(const char *patchPath,
Path checkedTargetPath(targetPath);
SVN_JNI_ERR(checkedTargetPath.error_occured(), );
+ // Should parameterize the following, instead of defaulting to FALSE
SVN_JNI_ERR(svn_client_patch(checkedPatchPath.c_str(),
checkedTargetPath.c_str(),
- dryRun, stripCount, reverse, ignoreWhitespace,
- removeTempfiles,
+ dryRun, stripCount, FALSE, reverse,
+ ignoreWhitespace, removeTempfiles,
PatchCallback::callback, callback,
ctx, requestPool.pool(),
requestPool.pool()), );
}
+
+ClientContext &
+SVNClient::getClientContext()
+{
+ return context;
+}
Modified: subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/bindings/javahl/native/SVNClient.h Wed Sep 15 19:32:26 2010
@@ -31,12 +31,10 @@
#include <string>
#include <jni.h>
#include "Path.h"
+#include "ClientContext.h"
class Revision;
class RevisionRange;
-class ClientNotifyCallback;
-class ConflictResolverCallback;
-class ProgressListener;
class Targets;
class JNIByteArray;
class Prompter;
@@ -46,6 +44,7 @@ class BlameCallback;
class ProplistCallback;
class LogMessageCallback;
class InfoCallback;
+class CommitCallback;
class ListCallback;
class StatusCallback;
class PatchCallback;
@@ -69,16 +68,6 @@ class SVNClient :public SVNBase
void unlock(Targets &targets, bool force);
void lock(Targets &targets, const char *comment, bool force);
jobject revProperties(const char *path, Revision &revision);
- void cancelOperation();
- void commitMessageHandler(CommitMessage *commitMessage);
- const char *getConfigDirectory();
-
- /**
- * Set the configuration directory, taking the usual steps to
- * ensure that Subversion's config file templates exist in the
- * specified location.
- */
- void setConfigDirectory(const char *configDir);
void blame(const char *path, Revision &pegRevision,
Revision &revisionStart, Revision &revisionEnd,
@@ -93,7 +82,7 @@ class SVNClient :public SVNBase
size_t bufSize);
void propertySet(const char *path, const char *name, const char *value,
svn_depth_t depth, StringArray &changelists, bool force,
- RevpropTable &revprops);
+ RevpropTable &revprops, CommitCallback *callback);
void properties(const char *path, Revision &revision,
Revision &pegRevision, svn_depth_t depth,
StringArray &changelists, ProplistCallback *callback);
@@ -114,9 +103,9 @@ class SVNClient :public SVNBase
bool ignoreAncestry, bool dryRun, bool recordOnly);
void mergeReintegrate(const char *path, Revision &pegRevision,
const char *localPath, bool dryRun);
- void doImport(const char *path, const char *url, const char *message,
+ void doImport(const char *path, const char *url, CommitMessage *message,
svn_depth_t depth, bool noIgnore, bool ignoreUnknownNodeTypes,
- RevpropTable &revprops);
+ RevpropTable &revprops, CommitCallback *callback);
jlong doSwitch(const char *path, const char *url, Revision &revision,
Revision &pegRevision, svn_depth_t depth,
bool depthIsSticky, bool ignoreExternals,
@@ -128,28 +117,28 @@ class SVNClient :public SVNBase
void resolve(const char *path, svn_depth_t depth,
svn_wc_conflict_choice_t choice);
void cleanup(const char *path);
- void mkdir(Targets &targets, const char *message, bool makeParents,
- RevpropTable &revprops);
+ void mkdir(Targets &targets, CommitMessage *message, bool makeParents,
+ RevpropTable &revprops, CommitCallback *callback);
void move(Targets &srcPaths, const char *destPath,
- const char *message, bool force, bool moveAsChild,
- bool makeParents, RevpropTable &revprops);
+ CommitMessage *message, bool force, bool moveAsChild,
+ bool makeParents, RevpropTable &revprops, CommitCallback *callback);
void copy(CopySources ©Sources, const char *destPath,
- const char *message, bool copyAsChild, bool makeParents,
- bool ignoreExternals, RevpropTable &revprops);
- jlong commit(Targets &targets, const char *message, svn_depth_t depth,
- bool noUnlock, bool keepChangelist,
- StringArray &changelists, RevpropTable &revprops);
+ CommitMessage *message, bool copyAsChild, bool makeParents,
+ bool ignoreExternals, RevpropTable &revprops,
+ CommitCallback *callback);
+ void commit(Targets &targets, CommitMessage *message, svn_depth_t depth,
+ bool noUnlock, bool keepChangelist,
+ StringArray &changelists, RevpropTable &revprops,
+ CommitCallback *callback);
jlongArray update(Targets &targets, Revision &revision, svn_depth_t depth,
bool depthIsSticky, bool ignoreExternals,
bool allowUnverObstructions);
void add(const char *path, svn_depth_t depth, bool force, bool no_ignore,
bool add_parents);
void revert(const char *path, svn_depth_t depth, StringArray &changelists);
- void remove(Targets &targets, const char *message, bool force,
- bool keep_local, RevpropTable &revprops);
- void notification2(ClientNotifyCallback *notify2);
- void setConflictResolver(ConflictResolverCallback *conflictResolver);
- void setProgressListener(ProgressListener *progressListener);
+ void remove(Targets &targets, CommitMessage *message, bool force,
+ bool keep_local, RevpropTable &revprops,
+ CommitCallback *callback);
jlong checkout(const char *moduleName, const char *destPath,
Revision &revision, Revision &pegRevsion, svn_depth_t depth,
bool ignoreExternals, bool allowUnverObstructions);
@@ -158,9 +147,6 @@ class SVNClient :public SVNBase
bool discoverPaths, bool includeMergedRevisions,
StringArray &revProps,
long limit, LogMessageCallback *callback);
- void setPrompt(Prompter *prompter);
- void password(const char *pi_password);
- void username(const char *pi_username);
jstring getAdminDirectoryName();
jboolean isAdminDirectory(const char *name);
void addToChangelist(Targets &srcPaths, const char *changelist,
@@ -205,14 +191,14 @@ class SVNClient :public SVNBase
svn_depth_t depth, StringArray &changelists,
bool ignoreAncestry, DiffSummaryReceiver &receiver);
+ ClientContext &getClientContext();
+
const char *getLastPath();
- void dispose(jobject jthis);
+ void dispose();
static SVNClient *getCppObject(jobject jthis);
- SVNClient();
+ SVNClient(jobject jthis_in);
virtual ~SVNClient();
private:
- static svn_error_t *checkCancel(void *cancelBaton);
- svn_client_ctx_t *getContext(const char *message);
svn_stream_t *createReadStream(apr_pool_t *pool, const char *path,
Revision &revision, Revision &pegRevision,
size_t &size);
@@ -228,31 +214,8 @@ class SVNClient :public SVNBase
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds);
- ClientNotifyCallback *m_notify2;
- ConflictResolverCallback *m_conflictResolver;
- ProgressListener *m_progressListener;
- Prompter *m_prompter;
Path m_lastPath;
- bool m_cancelOperation;
- CommitMessage *m_commitMessage;
-
- /**
- * Implements the svn_client_get_commit_log3_t API.
- */
- static svn_error_t *getCommitMessage(const char **log_msg,
- const char **tmp_file,
- const apr_array_header_t *
- commit_items,
- void *baton,
- apr_pool_t *pool);
- /**
- * Produce a baton for the getCommitMessage() callback.
- */
- void *getCommitMessageBaton(const char *message);
-
- std::string m_userName;
- std::string m_passWord;
- std::string m_configDir;
+ ClientContext context;
};
#endif // SVNCLIENT_H