Author: brane
Date: Sun Feb 8 04:00:13 2015
New Revision: 1658132
URL: http://svn.apache.org/r1658132
Log:
On the pin-externals branch: Implement explicit externals list
conversion for ISVNClient.copy with pinned exrernals.
* BRANCH-README: New; add minimal TODO list.
* subversion/bindings/javahl/native/SVNClient.cpp
(PinList, PinListFunctor, PinMap, PinMapFunctor): New.
(get_externals_to_pin): Converts Java externals refs to
the format required by svn_client_copy7.
(SVNClient::copy): Convert externals-to-pin and handle exceptions.
Added:
subversion/branches/pin-externals/BRANCH-README (with props)
Modified:
subversion/branches/pin-externals/subversion/bindings/javahl/native/SVNClient.cpp
Added: subversion/branches/pin-externals/BRANCH-README
URL:
http://svn.apache.org/viewvc/subversion/branches/pin-externals/BRANCH-README?rev=1658132&view=auto
==============================================================================
--- subversion/branches/pin-externals/BRANCH-README (added)
+++ subversion/branches/pin-externals/BRANCH-README Sun Feb 8 04:00:13 2015
@@ -0,0 +1,3 @@
+TODO:
+ - Write a proper BRANCH-README file.
+ - JavaHL test for ISVNClient.copy with explicit list of externals to pin.
Propchange: subversion/branches/pin-externals/BRANCH-README
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
subversion/branches/pin-externals/subversion/bindings/javahl/native/SVNClient.cpp
URL:
http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/bindings/javahl/native/SVNClient.cpp?rev=1658132&r1=1658131&r2=1658132&view=diff
==============================================================================
---
subversion/branches/pin-externals/subversion/bindings/javahl/native/SVNClient.cpp
(original)
+++
subversion/branches/pin-externals/subversion/bindings/javahl/native/SVNClient.cpp
Sun Feb 8 04:00:13 2015
@@ -70,11 +70,19 @@
#include "svn_diff.h"
#include "svn_config.h"
#include "svn_io.h"
+#include "svn_hash.h"
#include "svn_dirent_uri.h"
#include "svn_path.h"
#include "svn_utf.h"
+#include "private/svn_subr_private.h"
#include "svn_private_config.h"
+#include "ExternalItem.hpp"
+#include "jniwrapper/jni_list.hpp"
+#include "jniwrapper/jni_stack.hpp"
+#include "jniwrapper/jni_string_map.hpp"
+
+
SVNClient::SVNClient(jobject jthis_in)
: m_lastPath("", pool), context(jthis_in, pool)
{
@@ -443,6 +451,71 @@ void SVNClient::commit(Targets &targets,
);
}
+
+namespace {
+typedef Java::ImmutableList<JavaHL::ExternalItem> PinList;
+typedef Java::ImmutableMap<PinList> PinMap;
+
+struct PinListFunctor
+{
+ explicit PinListFunctor(const Java::Env& env, SVN::Pool& pool, int refs_len)
+ : m_pool(pool),
+ m_refs(apr_array_make(pool.getPool(), refs_len,
+ sizeof(svn_wc_external_item2_t*)))
+ {}
+
+ void operator()(const JavaHL::ExternalItem& item)
+ {
+ APR_ARRAY_PUSH(m_refs, svn_wc_external_item2_t*) =
+ item.get_external_item(m_pool);
+ }
+
+ SVN::Pool& m_pool;
+ apr_array_header_t *m_refs;
+};
+
+struct PinMapFunctor
+{
+ explicit PinMapFunctor(const Java::Env& env, SVN::Pool& pool)
+ : m_env(env),
+ m_pool(pool),
+ m_pin_set(svn_hash__make(pool.getPool()))
+ {}
+
+ void operator()(const std::string& path, const PinList& refs)
+ {
+ PinListFunctor lf(m_env, m_pool, refs.length());
+ refs.for_each(lf);
+ const char* key = static_cast<const char*>(
+ apr_pmemdup(m_pool.getPool(), path.c_str(), path.size() + 1));
+ svn_hash_sets(m_pin_set, key, lf.m_refs);
+ }
+
+ const Java::Env& m_env;
+ SVN::Pool& m_pool;
+ apr_hash_t *m_pin_set;
+};
+
+apr_hash_t *get_externals_to_pin(jobject jexternalsToPin, SVN::Pool& pool)
+{
+ if (!jexternalsToPin)
+ return NULL;
+
+ const Java::Env env;
+ JNIEnv *jenv = env.get();
+
+ try
+ {
+ PinMap pin_map(env, jexternalsToPin);
+ PinMapFunctor mf(env, pool);
+ pin_map.for_each(mf);
+ return mf.m_pin_set;
+ }
+ SVN_JAVAHL_JNI_CATCH;
+ return NULL;
+}
+} // anonymous namespace
+
void SVNClient::copy(CopySources ©Sources, const char *destPath,
CommitMessage *message, bool copyAsChild,
bool makeParents, bool ignoreExternals,
@@ -461,11 +534,13 @@ void SVNClient::copy(CopySources ©So
if (ctx == NULL)
return;
- SVN_JNI_ERR(svn_client_copy7(srcs, destinationPath.c_str(),
- copyAsChild, makeParents, ignoreExternals,
- pinExternals, /* FIXME: */NULL,
- revprops.hash(subPool),
- CommitCallback::callback, callback,
+ apr_hash_t *pin_set = get_externals_to_pin(jexternalsToPin, subPool);
+ if (!JNIUtil::isJavaExceptionThrown())
+ SVN_JNI_ERR(svn_client_copy7(srcs, destinationPath.c_str(),
+ copyAsChild, makeParents, ignoreExternals,
+ pinExternals, pin_set,
+ revprops.hash(subPool),
+ CommitCallback::callback, callback,
ctx, subPool.getPool()), );
}