Author: hwright
Date: Thu Sep 22 14:00:10 2011
New Revision: 1174145
URL: http://svn.apache.org/viewvc?rev=1174145&view=rev
Log:
JavaHL: Update to use the stream-based diff API.
[ in subversion/bindings/javahl/ ]
* native/SVNClient.h
(diff, diff, diff): Use an OutputStream, rather than a output filename.
* native/org_apache_subversion_javahl_SVNClient.cpp
(Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ):
Renamed from this...
(Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_io_OutputStream_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ):
...to this. Wrap stream and pass to C++ layer.
(Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ):
Rename from this...
(Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_io_OutputStream_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ):
...to this. Wrap stream and pass to the C++ layer.
* native/SVNClient.cpp
(diff): Use the output stream, and don't mess with an output file.
(diff, diff): Update wrappers.
* src/org/apache/subversion/javahl/SVNClient.java
(diff, diff): Deprecate, implement as wrapper.
(diff, diff): New streamy version.
* src/org/apache/subversion/javahl/ISVNClient.java
(diff, diff): New.
Modified:
subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=1174145&r1=1174144&r2=1174145&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Thu Sep 22
14:00:10 2011
@@ -932,12 +932,11 @@ void SVNClient::propertySetRemote(const
void SVNClient::diff(const char *target1, Revision &revision1,
const char *target2, Revision &revision2,
Revision *pegRevision, const char *relativeToDir,
- const char *outfileName, svn_depth_t depth,
+ OutputStream &outputStream, svn_depth_t depth,
StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds)
{
- svn_error_t *err;
SVN::Pool subPool(pool);
const char *c_relToDir = relativeToDir ?
svn_dirent_canonicalize(relativeToDir, subPool.getPool()) :
@@ -948,7 +947,6 @@ void SVNClient::diff(const char *target1
if (pegRevision == NULL)
SVN_JNI_NULL_PTR_EX(target2, "target2", );
- SVN_JNI_NULL_PTR_EX(outfileName, "outfileName", );
svn_client_ctx_t *ctx = context.getContext(NULL, subPool);
if (ctx == NULL)
return;
@@ -956,26 +954,13 @@ void SVNClient::diff(const char *target1
Path path1(target1, subPool);
SVN_JNI_ERR(path1.error_occured(), );
- apr_file_t *outfile = NULL;
- apr_status_t rv =
- apr_file_open(&outfile,
- svn_dirent_internal_style(outfileName,
- subPool.getPool()),
- APR_CREATE|APR_WRITE|APR_TRUNCATE , APR_OS_DEFAULT,
- subPool.getPool());
- if (rv != APR_SUCCESS)
- {
- SVN_JNI_ERR(svn_error_createf(rv, NULL, _("Cannot open file '%s'"),
- outfileName), );
- }
-
// We don't use any options to diff.
apr_array_header_t *diffOptions = apr_array_make(subPool.getPool(),
0, sizeof(char *));
if (pegRevision)
{
- err = svn_client_diff_peg5(diffOptions,
+ SVN_JNI_ERR(svn_client_diff_peg6(diffOptions,
path1.c_str(),
pegRevision->revision(),
revision1.revision(),
@@ -988,26 +973,20 @@ void SVNClient::diff(const char *target1
force,
FALSE,
SVN_APR_LOCALE_CHARSET,
- outfile,
+ outputStream.getStream(subPool),
NULL /* error file */,
changelists.array(subPool),
ctx,
- subPool.getPool());
+ subPool.getPool()),
+ );
}
else
{
// "Regular" diff (without a peg revision).
Path path2(target2, subPool);
- err = path2.error_occured();
- if (err)
- {
- if (outfile)
- goto cleanup;
-
- SVN_JNI_ERR(err, );
- }
+ SVN_JNI_ERR(path2.error_occured(), );
- err = svn_client_diff5(diffOptions,
+ SVN_JNI_ERR(svn_client_diff6(diffOptions,
path1.c_str(),
revision1.revision(),
path2.c_str(),
@@ -1020,47 +999,36 @@ void SVNClient::diff(const char *target1
force,
FALSE,
SVN_APR_LOCALE_CHARSET,
- outfile,
- NULL /* error file */,
+ outputStream.getStream(subPool),
+ NULL /* error stream */,
changelists.array(subPool),
ctx,
- subPool.getPool());
+ subPool.getPool()),
+ );
}
-
-cleanup:
- rv = apr_file_close(outfile);
- if (rv != APR_SUCCESS)
- {
- svn_error_clear(err);
-
- SVN_JNI_ERR(svn_error_createf(rv, NULL, _("Cannot close file '%s'"),
- outfileName), );
- }
-
- SVN_JNI_ERR(err, );
}
void SVNClient::diff(const char *target1, Revision &revision1,
const char *target2, Revision &revision2,
- const char *relativeToDir, const char *outfileName,
+ const char *relativeToDir, OutputStream &outputStream,
svn_depth_t depth, StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds)
{
diff(target1, revision1, target2, revision2, NULL, relativeToDir,
- outfileName, depth, changelists, ignoreAncestry, noDiffDelete, force,
+ outputStream, depth, changelists, ignoreAncestry, noDiffDelete, force,
showCopiesAsAdds);
}
void SVNClient::diff(const char *target, Revision &pegRevision,
Revision &startRevision, Revision &endRevision,
- const char *relativeToDir, const char *outfileName,
+ const char *relativeToDir, OutputStream &outputStream,
svn_depth_t depth, StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds)
{
diff(target, startRevision, NULL, endRevision, &pegRevision,
- relativeToDir, outfileName, depth, changelists,
+ relativeToDir, outputStream, depth, changelists,
ignoreAncestry, noDiffDelete, force, showCopiesAsAdds);
}
Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.h?rev=1174145&r1=1174144&r2=1174145&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.h Thu Sep 22
14:00:10 2011
@@ -174,13 +174,13 @@ class SVNClient :public SVNBase
Revision &revision, Revision &pegRevision);
void diff(const char *target1, Revision &revision1,
const char *target2, Revision &revision2,
- const char *relativeToDir, const char *outfileName,
+ const char *relativeToDir, OutputStream &outputStream,
svn_depth_t depth, StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds);
void diff(const char *target, Revision &pegevision,
Revision &startRevision, Revision &endRevision,
- const char *relativeToDir, const char *outfileName,
+ const char *relativeToDir, OutputStream &outputStream,
svn_depth_t depth, StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds);
@@ -209,7 +209,8 @@ class SVNClient :public SVNBase
void diff(const char *target1, Revision &revision1,
const char *target2, Revision &revision2,
Revision *pegRevision, const char *relativeToDir,
- const char *outfileName, svn_depth_t depth, StringArray
&changelists,
+ OutputStream &outputStream, svn_depth_t depth,
+ StringArray &changelists,
bool ignoreAncestry, bool noDiffDelete, bool force,
bool showCopiesAsAdds);
Modified:
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=1174145&r1=1174144&r2=1174145&view=diff
==============================================================================
---
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
(original)
+++
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
Thu Sep 22 14:00:10 2011
@@ -1171,10 +1171,10 @@ JNIEXPORT void JNICALL Java_org_apache_s
}
JNIEXPORT void JNICALL
-Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ
+Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_io_OutputStream_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ
(JNIEnv *env, jobject jthis, jstring jtarget1, jobject jrevision1,
jstring jtarget2, jobject jrevision2, jstring jrelativeToDir,
- jstring joutfileName, jobject jdepth, jobject jchangelists,
+ jobject jstream, jobject jdepth, jobject jchangelists,
jboolean jignoreAncestry, jboolean jnoDiffDeleted, jboolean jforce,
jboolean jcopiesAsAdds)
{
@@ -1205,7 +1205,7 @@ Java_org_apache_subversion_javahl_SVNCli
if (JNIUtil::isExceptionThrown())
return;
- JNIStringHolder outfileName(joutfileName);
+ OutputStream dataOut(jstream);
if (JNIUtil::isExceptionThrown())
return;
@@ -1213,7 +1213,7 @@ Java_org_apache_subversion_javahl_SVNCli
if (JNIUtil::isExceptionThrown())
return;
- cl->diff(target1, revision1, target2, revision2, relativeToDir, outfileName,
+ cl->diff(target1, revision1, target2, revision2, relativeToDir, dataOut,
EnumMapper::toDepth(jdepth), changelists,
jignoreAncestry ? true:false,
jnoDiffDeleted ? true:false, jforce ? true:false,
@@ -1221,10 +1221,10 @@ Java_org_apache_subversion_javahl_SVNCli
}
JNIEXPORT void JNICALL
-Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ
+Java_org_apache_subversion_javahl_SVNClient_diff__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Ljava_io_OutputStream_2Lorg_apache_subversion_javahl_types_Depth_2Ljava_util_Collection_2ZZZZ
(JNIEnv *env, jobject jthis, jstring jtarget, jobject jpegRevision,
jobject jstartRevision, jobject jendRevision, jstring jrelativeToDir,
- jstring joutfileName, jobject jdepth, jobject jchangelists,
+ jobject jstream, jobject jdepth, jobject jchangelists,
jboolean jignoreAncestry, jboolean jnoDiffDeleted, jboolean jforce,
jboolean jcopiesAsAdds)
{
@@ -1251,7 +1251,7 @@ Java_org_apache_subversion_javahl_SVNCli
if (JNIUtil::isExceptionThrown())
return;
- JNIStringHolder outfileName(joutfileName);
+ OutputStream dataOut(jstream);
if (JNIUtil::isExceptionThrown())
return;
@@ -1264,7 +1264,7 @@ Java_org_apache_subversion_javahl_SVNCli
return;
cl->diff(target, pegRevision, startRevision, endRevision, relativeToDir,
- outfileName, EnumMapper::toDepth(jdepth), changelists,
+ dataOut, EnumMapper::toDepth(jdepth), changelists,
jignoreAncestry ? true:false,
jnoDiffDeleted ? true:false, jforce ? true:false,
jcopiesAsAdds ? true:false);
Modified:
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java?rev=1174145&r1=1174144&r2=1174145&view=diff
==============================================================================
---
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
(original)
+++
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
Thu Sep 22 14:00:10 2011
@@ -524,6 +524,13 @@ public interface ISVNClient
* @throws ClientException
*/
void diff(String target1, Revision revision1, String target2,
+ Revision revision2, String relativeToDir, OutputStream outStream,
+ Depth depth, Collection<String> changelists,
+ boolean ignoreAncestry, boolean noDiffDeleted, boolean force,
+ boolean copiesAsAdds)
+ throws ClientException;
+
+ void diff(String target1, Revision revision1, String target2,
Revision revision2, String relativeToDir, String outFileName,
Depth depth, Collection<String> changelists,
boolean ignoreAncestry, boolean noDiffDeleted, boolean force,
@@ -548,6 +555,14 @@ public interface ISVNClient
* @throws ClientException
*/
void diff(String target, Revision pegRevision, Revision startRevision,
+ Revision endRevision, String relativeToDir,
+ OutputStream outStream,
+ Depth depth, Collection<String> changelists,
+ boolean ignoreAncestry, boolean noDiffDeleted, boolean force,
+ boolean copiesAsAdds)
+ throws ClientException;
+
+ void diff(String target, Revision pegRevision, Revision startRevision,
Revision endRevision, String relativeToDir, String outFileName,
Depth depth, Collection<String> changelists,
boolean ignoreAncestry, boolean noDiffDeleted, boolean force,
Modified:
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=1174145&r1=1174144&r2=1174145&view=diff
==============================================================================
---
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
(original)
+++
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Thu Sep 22 14:00:10 2011
@@ -27,6 +27,8 @@ import org.apache.subversion.javahl.call
import org.apache.subversion.javahl.types.*;
import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
import java.io.ByteArrayOutputStream;
import java.util.Collection;
@@ -264,17 +266,53 @@ public class SVNClient implements ISVNCl
LogMessageCallback callback)
throws ClientException;
+ public void diff(String target1, Revision revision1, String target2,
+ Revision revision2, String relativeToDir,
+ String outFileName, Depth depth,
+ Collection<String> changelists,
+ boolean ignoreAncestry, boolean noDiffDeleted,
+ boolean force, boolean copiesAsAdds)
+ throws ClientException
+ {
+ try {
+ OutputStream stream = new FileOutputStream(outFileName);
+ diff(target1, revision1, target2, revision2, relativeToDir,
+ stream, depth, changelists, ignoreAncestry, noDiffDeleted,
+ force, copiesAsAdds);
+ } catch (FileNotFoundException ex) {
+ throw ClientException.fromException(ex);
+ }
+ }
+
public native void diff(String target1, Revision revision1, String target2,
Revision revision2, String relativeToDir,
- String outFileName, Depth depth,
+ OutputStream stream, Depth depth,
Collection<String> changelists,
boolean ignoreAncestry, boolean noDiffDeleted,
boolean force, boolean copiesAsAdds)
throws ClientException;
+ public void diff(String target, Revision pegRevision,
+ Revision startRevision, Revision endRevision,
+ String relativeToDir, String outFileName,
+ Depth depth, Collection<String> changelists,
+ boolean ignoreAncestry, boolean noDiffDeleted,
+ boolean force, boolean copiesAsAdds)
+ throws ClientException
+ {
+ try {
+ OutputStream stream = new FileOutputStream(outFileName);
+ diff(target, pegRevision, startRevision, endRevision,
+ relativeToDir, stream, depth, changelists, ignoreAncestry,
+ noDiffDeleted, force, copiesAsAdds);
+ } catch (FileNotFoundException ex) {
+ throw ClientException.fromException(ex);
+ }
+ }
+
public native void diff(String target, Revision pegRevision,
Revision startRevision, Revision endRevision,
- String relativeToDir, String outFileName,
+ String relativeToDir, OutputStream stream,
Depth depth, Collection<String> changelists,
boolean ignoreAncestry, boolean noDiffDeleted,
boolean force, boolean copiesAsAdds)