subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1518879 - in /subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl: ./ native/ src/org/apache/subversion/javahl/ src/org/apache/subversion/javahl/util/ tests/org/apache/subversion/javahl/
Date Fri, 30 Aug 2013 01:50:38 GMT
Author: brane
Date: Fri Aug 30 01:50:37 2013
New Revision: 1518879

URL: http://svn.apache.org/r1518879
Log:
On the javahl-1.7-extensions branch: Synced JavaHL with trunk up to r1518878.

Modified:
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/   (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/Iterator.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/Iterator.h
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/LockTokenTable.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/LockTokenTable.h
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSession.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSession.h
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSessionContext.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSessionContext.h
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RevisionRangeList.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RevisionRangeList.h
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_types_RevisionRangeList.cpp
  (props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp
  (contents, props changed)
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNUtil.java
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/util/DiffLib.java
    subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/
------------------------------------------------------------------------------
  Merged /subversion/trunk/subversion/bindings/javahl:r1512373-1518878

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/Iterator.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/Iterator.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/LockTokenTable.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/LockTokenTable.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSession.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSession.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSessionContext.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RemoteSessionContext.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RevisionRangeList.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/RevisionRangeList.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_ConfigImpl_Category.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteSession.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_types_RevisionRangeList.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp?rev=1518879&r1=1518878&r2=1518879&view=diff
==============================================================================
--- subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp
(original)
+++ subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp
Fri Aug 30 01:50:37 2013
@@ -35,7 +35,86 @@
 
 #include "svn_diff.h"
 
-JNIEXPORT void JNICALL
+JNIEXPORT jboolean JNICALL
+Java_org_apache_subversion_javahl_util_DiffLib_nativeFileDiff(
+    JNIEnv* env, jobject jthis,
+    jstring joriginal_file,
+    jstring jmodified_file,
+
+    jint jignore_space_ordinal,
+    jboolean jignore_eol_style,
+    jboolean jshow_c_function,
+
+    jstring joriginal_header,
+    jstring jmodified_header,
+    jstring jheader_encoding,
+    jstring jrelative_to_dir,
+
+    jobject jresult_stream)
+{
+  JNIEntry(DiffLib, nativeFileDiff);
+
+  // Using a "global" request pool since we don't keep a context with
+  // its own pool around for these functions.
+  SVN::Pool pool;
+
+  Path original(joriginal_file, pool);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+  SVN_JNI_ERR(original.error_occurred(), false);
+
+  Path modified(jmodified_file, pool);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+  SVN_JNI_ERR(modified.error_occurred(), false);
+
+  svn_diff_t* diff;
+  svn_diff_file_options_t* diff_options =
+    svn_diff_file_options_create(pool.getPool());
+  diff_options->ignore_space =
+    svn_diff_file_ignore_space_t(jignore_space_ordinal);
+  diff_options->ignore_eol_style = svn_boolean_t(jignore_eol_style);
+  diff_options->show_c_function = svn_boolean_t(jshow_c_function);
+  SVN_JNI_ERR(svn_diff_file_diff_2(&diff,
+                                   original.c_str(),
+                                   modified.c_str(),
+                                   diff_options,
+                                   pool.getPool()),
+              false);
+
+  const jboolean diffs = svn_diff_contains_diffs(diff);
+
+  JNIStringHolder original_header(joriginal_header);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+
+  JNIStringHolder modified_header(jmodified_header);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+
+  JNIStringHolder header_encoding(jheader_encoding);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+
+  JNIStringHolder relative_to_dir(jrelative_to_dir);
+  if (JNIUtil::isJavaExceptionThrown())
+    return false;
+
+  OutputStream result_stream(jresult_stream);
+
+  SVN_JNI_ERR(svn_diff_file_output_unified3(
+                  result_stream.getStream(pool), diff,
+                  original.c_str(), modified.c_str(),
+                  original_header.c_str(), modified_header.c_str(),
+                  header_encoding.c_str(), relative_to_dir.c_str(),
+                  diff_options->show_c_function,
+                  pool.getPool()),
+              false);
+
+  return diffs;
+}
+
+JNIEXPORT jboolean JNICALL
 Java_org_apache_subversion_javahl_util_DiffLib_nativeFileMerge(
     JNIEnv* env, jobject jthis,
     jstring joriginal_file,
@@ -62,18 +141,18 @@ Java_org_apache_subversion_javahl_util_D
 
   Path original(joriginal_file, pool);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
-  SVN_JNI_ERR(original.error_occurred(),);
+    return false;
+  SVN_JNI_ERR(original.error_occurred(), false);
 
   Path modified(jmodified_file, pool);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
-  SVN_JNI_ERR(modified.error_occurred(),);
+    return false;
+  SVN_JNI_ERR(modified.error_occurred(), false);
 
   Path latest(jlatest_file, pool);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
-  SVN_JNI_ERR(latest.error_occurred(),);
+    return false;
+  SVN_JNI_ERR(latest.error_occurred(), false);
 
   svn_diff_t* diff;
   svn_diff_file_options_t* diff_options =
@@ -87,24 +166,27 @@ Java_org_apache_subversion_javahl_util_D
                                     modified.c_str(),
                                     latest.c_str(),
                                     diff_options,
-                                    pool.getPool()),);
+                                    pool.getPool()),
+              false);
+
+  const jboolean conflicts = svn_diff_contains_conflicts(diff);
 
   JNIStringHolder conflict_original(jconflict_original);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
+    return false;
 
   JNIStringHolder conflict_modified(jconflict_modified);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
+    return false;
 
   JNIStringHolder conflict_latest(jconflict_latest);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
+    return false;
 
   JNIStringHolder conflict_separator(jconflict_separator);
   if (JNIUtil::isJavaExceptionThrown())
-    return;
-  
+    return false;
+
   OutputStream result_stream(jresult_stream);
 
   SVN_JNI_ERR(svn_diff_file_output_merge2(
@@ -115,5 +197,8 @@ Java_org_apache_subversion_javahl_util_D
                   conflict_latest.c_str(),
                   conflict_separator.c_str(),
                   svn_diff_conflict_display_style_t(jconflict_style_ordinal),
-                  pool.getPool()),);
+                  pool.getPool()),
+              false);
+
+  return conflicts;
 }

Propchange: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/native/org_apache_subversion_javahl_util_DiffLib.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNUtil.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNUtil.java?rev=1518879&r1=1518878&r2=1518879&view=diff
==============================================================================
--- subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNUtil.java
(original)
+++ subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNUtil.java
Fri Aug 30 01:50:37 2013
@@ -108,15 +108,60 @@ public class SVNUtil
     }
 
     /**
-     * Given three versions of a file, base
-     * (<code>originalFile</code>), incoming
-     * (<code>modifiedFile</code>) and current
+     * Given two versions of a file, base (<code>originalFile</code>)
+     * and current (<code>modifiedFile</code>), show differences between
+     * them in unified diff format.
+     *
+     * @param originalFile The base file version (unmodified)
+     * @param modifiedFile The incoming file version (locally modified)
+     * @param diffOptions Options controlling how files are compared.
+     *        May be <code>null</code>.
+     * @param originalHeader The header to display for the base file
+     *        in the unidiff index block. If it is <code>null</code>,
+     *        the <code>originalFile</code> path and its modification
+     *        time will be used instead.
+     * @param modifiedHeader The header to display for the current
+     *        file in the unidiff index block. If it is <code>null</code>,
+     *        the <code>currentFile</code> path and its modification
+     *        time will be used instead.
+     * @param headerEncoding The character encoding of the unidiff headers.
+     * @param relativeToDir If this parameter is not <null>, it must
+     *        be the path of a (possibly non-immediate) parent of both
+     *        <code>originalFile</code> and <code>modifiedFile</code>.
+     *        This path will be stripped from the beginning of those
+     *        file names if they are used in the unidiff index header.
+     * @param resultStream The stream that receives the merged output.
+     * @return <code>true</code> if there were differences between the files.
+     * @throws ClientException
+     */
+    public static boolean fileDiff(String originalFile,
+                                   String modifiedFile,
+                                   SVNUtil.DiffOptions diffOptions,
+
+                                   String originalHeader,
+                                   String modifiedHeader,
+                                   String headerEncoding,
+                                   String relativeToDir,
+
+                                   OutputStream resultStream)
+        throws ClientException
+    {
+        return new DiffLib().fileDiff(originalFile, modifiedFile, diffOptions,
+                                      originalHeader, modifiedHeader,
+                                      headerEncoding,
+                                      relativeToDir, resultStream);
+    }
+
+
+    /**
+     * Given three versions of a file, base (<code>originalFile</code>),
+     * incoming (<code>modifiedFile</code>) and current
      * (<code>latestFile</code>, produce a merged result, possibly
      * displaying conflict markers.
      *
      * @param originalFile The base file version (common ancestor)
      * @param modifiedFile The incoming file version (modified elsewhere)
-     * @param latestFile The current file version (modified locally)
+     * @param latestFile The current file version (locally modified)
      * @param diffOptions Options controlling how files are compared.
      *        May be <code>null</code>.
      * @param conflictOriginal Optional custom conflict marker for
@@ -128,25 +173,27 @@ public class SVNUtil
      * @param conflictSeparator Optional custom conflict separator.
      * @param conflictStyle Determines how conflicts are displayed.
      * @param resultStream The stream that receives the merged output.
+     * @return <code>true</code> if there were any conflicts.
+     * @throws ClientException
      */
-    public static void FileMerge(String originalFile,
-                                 String modifiedFile,
-                                 String latestFile,
-                                 DiffOptions diffOptions,
-
-                                 String conflictOriginal,
-                                 String conflictModified,
-                                 String conflictLatest,
-                                 String conflictSeparator,
-                                 ConflictDisplayStyle conflictStyle,
+    public static boolean fileMerge(String originalFile,
+                                    String modifiedFile,
+                                    String latestFile,
+                                    DiffOptions diffOptions,
+
+                                    String conflictOriginal,
+                                    String conflictModified,
+                                    String conflictLatest,
+                                    String conflictSeparator,
+                                    ConflictDisplayStyle conflictStyle,
 
-                                 OutputStream resultStream)
+                                    OutputStream resultStream)
         throws ClientException
     {
-        new DiffLib().FileMerge(originalFile, modifiedFile, latestFile,
-                                diffOptions,
-                                conflictOriginal, conflictModified,
-                                conflictLatest, conflictSeparator,
-                                conflictStyle, resultStream);
+        return new DiffLib().fileMerge(originalFile, modifiedFile, latestFile,
+                                       diffOptions,
+                                       conflictOriginal, conflictModified,
+                                       conflictLatest, conflictSeparator,
+                                       conflictStyle, resultStream);
     }
-}
\ No newline at end of file
+}

Modified: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/util/DiffLib.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/util/DiffLib.java?rev=1518879&r1=1518878&r2=1518879&view=diff
==============================================================================
--- subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/util/DiffLib.java
(original)
+++ subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/src/org/apache/subversion/javahl/util/DiffLib.java
Fri Aug 30 01:50:37 2013
@@ -43,63 +43,104 @@ public class DiffLib
         NativeResources.loadNativeLibrary();
     }
 
-    /** @see ISVNUtil.FileMerge */
-    public void FileMerge(String originalFile,
-                          String modifiedFile,
-                          String latestFile,
-                          SVNUtil.DiffOptions diffOptions,
-
-                          String conflictOriginal,
-                          String conflictModified,
-                          String conflictLatest,
-                          String conflistSeparator,
-                          SVNUtil.ConflictDisplayStyle conflictStyle,
+    /** @see ISVNUtil.fileDiff */
+    public boolean fileDiff(String originalFile,
+                            String modifiedFile,
+                            SVNUtil.DiffOptions diffOptions,
+
+                            String originalHeader,
+                            String modifiedHeader,
+                            String headerEncoding,
+                            String relativeToDir,
 
-                          OutputStream resultStream)
+                            OutputStream resultStream)
         throws ClientException
     {
-        nativeFileMerge(originalFile,
-                        modifiedFile,
-                        latestFile,
-
-                        // Interpret the diff options
-                        (diffOptions == null
-                         ? SVNUtil.DiffOptions.IgnoreSpace.none.ordinal()
-                         : diffOptions.ignoreSpace.ordinal()),
-                        (diffOptions == null ? false
-                         : diffOptions.ignoreEolStyle),
-                        (diffOptions == null ? false
-                         : diffOptions.showCFunction),
-
-                        conflictOriginal,
-                        conflictModified,
-                        conflictLatest,
-                        conflistSeparator,
+        return nativeFileDiff(originalFile, modifiedFile,
 
-                        // Interpret the conflict style
-                        conflictStyle.ordinal(),
+                              // Interpret the diff options
+                              (diffOptions == null
+                               ? SVNUtil.DiffOptions.IgnoreSpace.none.ordinal()
+                               : diffOptions.ignoreSpace.ordinal()),
+                              (diffOptions == null ? false
+                               : diffOptions.ignoreEolStyle),
+                              (diffOptions == null ? false
+                               : diffOptions.showCFunction),
 
-                        resultStream);
+                              originalHeader, modifiedHeader, headerEncoding,
+                              relativeToDir, resultStream);
     }
 
     private native
-        void nativeFileMerge(String originalFile,
+        boolean nativeFileDiff(String originalFile,
+                               String modifiedFile,
+
+                               // Interpreted diff options
+                               int ignoreSpace,
+                               boolean ignoreEolStyle,
+                               boolean showCFunction,
+
+                               String originalHeader,
+                               String modifiedHeader,
+                               String headerEncoding,
+                               String relativeToDir,
+
+                               OutputStream resultStream)
+        throws ClientException;
+
+    /** @see ISVNUtil.fileMerge */
+    public boolean fileMerge(String originalFile,
                              String modifiedFile,
                              String latestFile,
-
-                             // Interpreted diff options
-                             int ignoreSpace,
-                             boolean ignoreEolStyle,
-                             boolean showCFunction,
+                             SVNUtil.DiffOptions diffOptions,
 
                              String conflictOriginal,
                              String conflictModified,
                              String conflictLatest,
                              String conflistSeparator,
-
-                             // Interpreted conflict display style
-                             int conflictStyle,
+                             SVNUtil.ConflictDisplayStyle conflictStyle,
 
                              OutputStream resultStream)
+        throws ClientException
+    {
+        return nativeFileMerge(originalFile, modifiedFile, latestFile,
+
+                               // Interpret the diff options
+                               (diffOptions == null
+                                ? SVNUtil.DiffOptions.IgnoreSpace.none.ordinal()
+                                : diffOptions.ignoreSpace.ordinal()),
+                               (diffOptions == null ? false
+                                : diffOptions.ignoreEolStyle),
+                               (diffOptions == null ? false
+                                : diffOptions.showCFunction),
+
+                               conflictOriginal, conflictModified,
+                               conflictLatest, conflistSeparator,
+
+                               // Interpret the conflict style
+                               conflictStyle.ordinal(),
+
+                               resultStream);
+    }
+
+    private native
+        boolean nativeFileMerge(String originalFile,
+                                String modifiedFile,
+                                String latestFile,
+
+                                // Interpreted diff options
+                                int ignoreSpace,
+                                boolean ignoreEolStyle,
+                                boolean showCFunction,
+
+                                String conflictOriginal,
+                                String conflictModified,
+                                String conflictLatest,
+                                String conflistSeparator,
+
+                                // Interpreted conflict display style
+                                int conflictStyle,
+
+                                OutputStream resultStream)
         throws ClientException;
 }

Modified: subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java?rev=1518879&r1=1518878&r2=1518879&view=diff
==============================================================================
--- subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
(original)
+++ subversion/branches/javahl-1.7-extensions/subversion/bindings/javahl/tests/org/apache/subversion/javahl/UtilTests.java
Fri Aug 30 01:50:37 2013
@@ -35,6 +35,8 @@ import org.junit.Assert;
  */
 public class UtilTests extends SVNTests
 {
+    private final static String NL = System.getProperty("line.separator");
+
     /**
      * Base name of all our tests.
      */
@@ -64,7 +66,7 @@ public class UtilTests extends SVNTests
         }
     }
 
-    private final byte[] fileContentsPrefix = "1\n2\n3\n4".getBytes();
+    private final byte[] fileContentsPrefix = "1\n2\n3\n4\n".getBytes();
     private final byte[] fileContentsSuffix = "N-3\nN-2\nN-1\nN\n".getBytes();
 
     private void writeFileContents(File file, String contents) throws Throwable
@@ -76,29 +78,55 @@ public class UtilTests extends SVNTests
         out.close();
     }
 
+    public void testFileDiff() throws Throwable
+    {
+        File original = File.createTempFile("merge", ".original", localTmp);
+        File modified = File.createTempFile("merge", ".modified", localTmp);
+
+        writeFileContents(original, "\noriginal\n\n");
+        writeFileContents(modified, "\nmodified\n\n");
+
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        boolean diffs =  SVNUtil.fileDiff(original.getAbsolutePath(),
+                                          modified.getAbsolutePath(),
+                                          null, "original", "modified", "UTF-8",
+                                          null, result);
+        assertTrue(diffs);
+
+        final byte[] expected = ("--- original" + NL +
+                                 "+++ modified" + NL +
+                                 "@@ -3,7 +3,7 @@" + NL +
+                                 " 3\n 4\n \n" +
+                                 "-original\n" +
+                                 "+modified\n" +
+                                 " \n N-3\n N-2\n").getBytes();
+        Assert.assertArrayEquals(expected, result.toByteArray());
+    }
+
     public void testFileMerge() throws Throwable
     {
         File original = File.createTempFile("merge", ".original", localTmp);
         File modified = File.createTempFile("merge", ".modified", localTmp);
         File latest = File.createTempFile("merge", ".latest", localTmp);
 
-        writeFileContents(original, "\noriginal\n");
-        writeFileContents(modified, "\nmodified\n");
-        writeFileContents(latest, "\nlatest\n");
+        writeFileContents(original, "\noriginal\n\n");
+        writeFileContents(modified, "\nmodified\n\n");
+        writeFileContents(latest, "\nlatest\n\n");
 
         ByteArrayOutputStream result = new ByteArrayOutputStream();
-        SVNUtil.FileMerge(original.getAbsolutePath(),
-                          modified.getAbsolutePath(),
-                          latest.getAbsolutePath(),
-                          null,
-                          "||||||| base",
-                          "<<<<<<< branch",
-                          ">>>>>>> local",
-                          "=======",
-                          SVNUtil.ConflictDisplayStyle.modified_original_latest,
-                          result);
+        boolean conflicts = SVNUtil.fileMerge(original.getAbsolutePath(),
+                                              modified.getAbsolutePath(),
+                                              latest.getAbsolutePath(),
+                                              null,
+                                              "||||||| base",
+                                              "<<<<<<< branch",
+                                              ">>>>>>> local",
+                                              "=======",
+                                              SVNUtil.ConflictDisplayStyle.modified_original_latest,
+                                              result);
+        assertTrue(conflicts);
 
-        final byte[] expected = ("1\n2\n3\n4\n" +
+        final byte[] expected = ("1\n2\n3\n4\n\n" +
                                  "<<<<<<< branch\n" +
                                  "modified\n" +
                                  "||||||| base\n" +
@@ -106,7 +134,7 @@ public class UtilTests extends SVNTests
                                  "=======\n" +
                                  "latest\n" +
                                  ">>>>>>> local\n" +
-                                 "N-3\nN-2\nN-1\nN\n").getBytes();
+                                 "\nN-3\nN-2\nN-1\nN\n").getBytes();
         Assert.assertArrayEquals(expected, result.toByteArray());
     }
 }



Mime
View raw message