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 [40/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/ subversi...

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_client/client-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_client/client-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_client/client-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_client/client-test.c Wed Sep 15 19:32:26 2010
@@ -342,16 +342,8 @@ test_patch(const svn_test_opts_t *opts,
 
   /* Check out the HEAD revision */
   SVN_ERR(svn_dirent_get_absolute(&cwd, "", pool));
-
-  if (cwd[0] == '/')
-    repos_url = apr_pstrcat(pool, "file://", cwd,
-                            "/test-patch-repos", NULL);
-  else
-    /* On Windows CWD is always in "X:/..." style */
-    repos_url = apr_pstrcat(pool, "file:///", cwd,
-                            "/test-patch-repos", NULL);
-
-  repos_url = svn_uri_canonicalize(repos_url, pool);
+  SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, "test-patch-repos",
+                                           pool));
 
   /* Put wc inside an unversioned directory.  Checking out a 1.7 wc
      directly inside a 1.6 wc doesn't work reliably, an intervening
@@ -387,7 +379,7 @@ test_patch(const svn_test_opts_t *opts,
   pcb.patched_tempfiles = apr_hash_make(pool);
   pcb.reject_tempfiles = apr_hash_make(pool);
   pcb.state_pool = pool;
-  SVN_ERR(svn_client_patch(patch_file_path, wc_path, FALSE, 0, FALSE,
+  SVN_ERR(svn_client_patch(patch_file_path, wc_path, FALSE, 0, FALSE, FALSE,
                            FALSE, FALSE, patch_collection_func, &pcb,
                            ctx, pool, pool));
   SVN_ERR(svn_io_file_close(patch_file, pool));
@@ -408,6 +400,151 @@ test_patch(const svn_test_opts_t *opts,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_wc_add_scenarios(const svn_test_opts_t *opts,
+                      apr_pool_t *pool)
+{
+  svn_repos_t *repos;
+  svn_fs_t *fs;
+  svn_fs_txn_t *txn;
+  svn_fs_root_t *txn_root;
+  const char *repos_url;
+  const char *wc_path;
+  svn_revnum_t committed_rev;
+  svn_client_ctx_t *ctx;
+  svn_opt_revision_t rev, peg_rev;
+  const char *new_dir_path;
+  const char *ex_file_path;
+  const char *ex_dir_path;
+  const char *ex2_dir_path;
+
+  /* Create a filesytem and repository. */
+  SVN_ERR(svn_test__create_repos(&repos, "test-wc-add-repos",
+                                 opts, pool));
+  fs = svn_repos_fs(repos);
+
+  /* Prepare a txn to receive the greek tree. */
+  SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, 0, pool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &committed_rev, txn, pool));
+
+  SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, "test-wc-add-repos",
+                                           pool));
+
+  SVN_ERR(svn_dirent_get_absolute(&wc_path, "test-wc-add", pool));
+
+  /* Remove old test data from the previous run */
+  SVN_ERR(svn_io_remove_dir2(wc_path, TRUE, NULL, NULL, pool));
+
+  SVN_ERR(svn_io_make_dir_recursively(wc_path, pool));
+  svn_test_add_dir_cleanup(wc_path);
+
+  rev.kind = svn_opt_revision_head;
+  peg_rev.kind = svn_opt_revision_unspecified;
+  SVN_ERR(svn_client_create_context(&ctx, pool));
+  /* Checkout greek tree as wc_path */
+  SVN_ERR(svn_client_checkout3(NULL, repos_url, wc_path, &peg_rev, &rev,
+                               svn_depth_infinity, FALSE, FALSE, ctx, pool));
+
+  /* Now checkout again as wc_path/NEW */
+  new_dir_path = svn_dirent_join(wc_path, "NEW", pool);
+  SVN_ERR(svn_client_checkout3(NULL, repos_url, new_dir_path, &peg_rev, &rev,
+                               svn_depth_infinity, FALSE, FALSE,
+                               ctx, pool));
+
+  ex_dir_path = svn_dirent_join(wc_path, "NEW_add", pool);
+  ex2_dir_path = svn_dirent_join(wc_path, "NEW_add2", pool);
+  SVN_ERR(svn_io_dir_make(ex_dir_path, APR_OS_DEFAULT, pool));
+  SVN_ERR(svn_io_dir_make(ex2_dir_path, APR_OS_DEFAULT, pool));
+
+  SVN_ERR(svn_io_open_uniquely_named(NULL, &ex_file_path, wc_path, "new_file",
+                                     NULL, svn_io_file_del_none, pool, pool));
+
+  /* Now use an access baton to do some add operations like an old client
+     might do */
+  {
+    svn_wc_adm_access_t *adm_access, *adm2;
+    svn_boolean_t locked;
+
+    SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, wc_path, TRUE, -1, NULL, NULL,
+                             pool));
+
+    /* ### The above svn_wc_adm_open3 creates a new svn_wc__db_t
+       ### instance.  The svn_wc_add3 below doesn't work while the
+       ### original svn_wc__db_t created by svn_client_create_context
+       ### remains open.  Closing the wc-context gets around the
+       ### problem but is obviously a hack. */
+    SVN_ERR(svn_wc_context_destroy(ctx->wc_ctx));
+    SVN_ERR(svn_wc_context_create(&ctx->wc_ctx, NULL, pool, pool));
+
+    /* Fix up copy as add with history */
+    SVN_ERR(svn_wc_add3(new_dir_path, adm_access, svn_depth_infinity,
+                        repos_url, committed_rev, NULL, NULL, NULL, NULL,
+                        pool));
+
+    /* Verify if the paths are locked now */
+    SVN_ERR(svn_wc_locked(&locked, wc_path, pool));
+    SVN_TEST_ASSERT(locked && "wc_path locked");
+    SVN_ERR(svn_wc_locked(&locked, new_dir_path, pool));
+    SVN_TEST_ASSERT(locked && "new_path locked");
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, new_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    /* Add local (new) file */
+    SVN_ERR(svn_wc_add3(ex_file_path, adm_access, svn_depth_unknown, NULL,
+                        SVN_INVALID_REVNUM, NULL, NULL, NULL, NULL, pool));
+
+    /* Add local (new) directory */
+    SVN_ERR(svn_wc_add3(ex_dir_path, adm_access, svn_depth_infinity, NULL,
+                        SVN_INVALID_REVNUM, NULL, NULL, NULL, NULL, pool));
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, ex_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    /* Add empty directory with copy trail */
+    SVN_ERR(svn_wc_add3(ex2_dir_path, adm_access, svn_depth_infinity,
+                        repos_url, committed_rev, NULL, NULL, NULL, NULL,
+                        pool));
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, ex2_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    SVN_ERR(svn_wc_adm_close2(adm_access, pool));
+  }
+
+  /* Some simple status calls to verify that the paths are added */
+  {
+    svn_wc_status3_t *status;
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, new_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && status->copied
+                    && !strcmp(status->repos_relpath, "NEW"));
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex_file_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && !status->copied);
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && !status->copied);
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex2_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && status->copied);
+  }
+
+  /* ### Add a commit? */
+
+  return SVN_NO_ERROR;
+}
+
 /* ========================================================================== */
 
 struct svn_test_descriptor_t test_funcs[] =
@@ -418,5 +555,6 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_PASS2(test_args_to_target_array,
                    "test svn_client_args_to_target_array"),
     SVN_TEST_OPTS_PASS(test_patch, "test svn_client_patch"),
+    SVN_TEST_OPTS_PASS(test_wc_add_scenarios, "test svn_wc_add3 scenarios"),
     SVN_TEST_NULL
   };

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_delta/delta-window-test.h
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_delta/delta-window-test.h?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_delta/delta-window-test.h (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_delta/delta-window-test.h Wed Sep 15 19:32:26 2010
@@ -26,9 +26,9 @@
 #define APR_WANT_STDIO
 #define APR_WANT_STRFUNC
 #include <apr_want.h>
-#include <apr_lib.h>
 
 #include "svn_delta.h"
+#include "svn_ctype.h"
 
 static apr_off_t
 delta_window_size_estimate(const svn_txdelta_window_t *window)
@@ -99,7 +99,7 @@ delta_window_print(const svn_txdelta_win
           for (tmp = offset; tmp < offset + length; ++tmp)
             {
               int const dat = window->new_data->data[tmp];
-              if (apr_iscntrl(dat) || !apr_isascii(dat))
+              if (svn_ctype_iscntrl(dat) || !svn_ctype_isascii(dat))
                 fprintf(stream, "\\%3.3o", dat & 0xff);
               else if (dat == '\\')
                 fputs("\\\\", stream);

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_diff/parse-diff-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_diff/parse-diff-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_diff/parse-diff-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_diff/parse-diff-test.c Wed Sep 15 19:32:26 2010
@@ -56,20 +56,14 @@ static const char *unidiff =
   "Name: svn:mergeinfo"                                                 NL
   ""                                                                    NL;
 
-/* ### We need to add plenty of more cases to this patch:
- * ### copy with modifications
- * ### rename
- * ### rename with modications 
- * ### add with modifications
- * ### delete with modifications*/
 static const char *git_unidiff =
   "Index: A/mu (deleted)"                                               NL
   "===================================================================" NL
-  "git --diff a/A/mu b/A/mu"                                            NL
+  "diff --git a/A/mu b/A/mu"                                            NL
   "deleted file mode 100644"                                            NL
   "Index: A/C/gamma"                                                    NL
   "===================================================================" NL
-  "git --diff a/A/C/gamma b/A/C/gamma"                                  NL
+  "diff --git a/A/C/gamma b/A/C/gamma"                                  NL
   "--- a/A/C/gamma\t(revision 2)"                                       NL
   "+++ b/A/C/gamma\t(working copy)"                                     NL
   "@@ -1 +1,2 @@"                                                       NL
@@ -77,15 +71,82 @@ static const char *git_unidiff =
   "+some more bytes to 'gamma'"                                         NL
   "Index: iota"                                                         NL
   "===================================================================" NL
-  "git --diff a/iota b/iota.copied"                                     NL
+  "diff --git a/iota b/iota.copied"                                     NL
   "copy from iota"                                                      NL
   "copy to iota.copied"                                                 NL
   "Index: new"                                                          NL
   "===================================================================" NL
-  "git --diff a/new b/new"                                              NL
+  "diff --git a/new b/new"                                              NL
   "new file mode 100644"                                                NL
   ""                                                                    NL;
 
+static const char *git_tree_and_text_unidiff =
+  "Index: iota.copied"                                                  NL
+  "===================================================================" NL
+  "diff --git a/iota b/iota.copied"                                     NL
+  "copy from iota"                                                      NL
+  "copy to iota.copied"                                                 NL
+  "--- a/iota\t(revision 2)"                                            NL
+  "+++ b/iota.copied\t(working copy)"                                   NL
+  "@@ -1 +1,2 @@"                                                       NL
+  " This is the file 'iota'."                                           NL
+  "+some more bytes to 'iota'"                                          NL
+  "Index: A/mu.moved"                                                   NL
+  "===================================================================" NL
+  "diff --git a/A/mu b/A/mu.moved"                                      NL
+  "rename from A/mu"                                                    NL
+  "rename to A/mu.moved"                                                NL
+  "--- a/A/mu\t(revision 2)"                                            NL
+  "+++ b/A/mu.moved\t(working copy)"                                    NL
+  "@@ -1 +1,2 @@"                                                       NL
+  " This is the file 'mu'."                                             NL
+  "+some more bytes to 'mu'"                                            NL
+  "Index: new"                                                          NL
+  "===================================================================" NL
+  "diff --git a/new b/new"                                              NL
+  "new file mode 100644"                                                NL
+  "--- /dev/null\t(revision 0)"                                         NL
+  "+++ b/new\t(working copy)"                                           NL
+  "@@ -0,0 +1 @@"                                                       NL
+  "+This is the file 'new'."                                            NL
+  "Index: A/B/lambda"                                                   NL
+  "===================================================================" NL
+  "diff --git a/A/B/lambda b/A/B/lambda"                                NL
+  "deleted file mode 100644"                                            NL
+  "--- a/A/B/lambda\t(revision 2)"                                      NL
+  "+++ /dev/null\t(working copy)"                                       NL
+  "@@ -1 +0,0 @@"                                                       NL
+  "-This is the file 'lambda'."                                         NL
+  ""                                                                    NL;
+
+  /* Only the last git diff header is valid. The other ones either misses a
+   * path element or has noise between lines that must be continous. */
+static const char *bad_git_diff_header =
+  "Index: iota.copied"                                                  NL
+  "===================================================================" NL
+  "diff --git a/foo1 b/"                                                NL
+  "diff --git a/foo2 b"                                                 NL
+  "diff --git a/foo3 "                                                  NL
+  "diff --git a/foo3 "                                                  NL
+  "diff --git foo4 b/foo4"                                              NL
+  "diff --git a/foo5 b/foo5"                                            NL
+  "random noise"                                                        NL
+  "copy from foo5"                                                      NL
+  "copy to foo5"                                                        NL
+  "diff --git a/foo6 b/foo6"                                            NL
+  "copy from foo6"                                                      NL
+  "random noise"                                                        NL
+  "copy to foo6"                                                        NL
+  "diff --git a/foo6 b/foo6"                                            NL
+  "copy from foo6"                                                      NL
+  "diff --git a/iota b/iota.copied"                                     NL
+  "copy from iota"                                                      NL
+  "copy to iota.copied"                                                 NL
+  "@@ -1 +1,2 @@"                                                       NL
+  " This is the file 'iota'."                                           NL
+  "+some more bytes to 'iota'"                                          NL
+  ""                                                                    NL;
+
   static const char *property_unidiff =
   "Index: iota"                                                         NL
   "===================================================================" NL
@@ -107,9 +168,19 @@ static const char *git_unidiff =
   "Property changes on: iota"                                           NL
   "___________________________________________________________________" NL
   "Modified: prop_mod"                                                  NL
-  "## -1 +1 ##"                                                         NL
+  "## -1,4 +1,4 ##"                                                     NL
   "-value"                                                              NL
-  "+new value"                                                          NL;
+  "+new value"                                                          NL
+  " context"                                                            NL
+  " context"                                                            NL
+  " context"                                                            NL
+  "## -10,4 +10,4 ##"                                                   NL
+  " context"                                                            NL
+  " context"                                                            NL
+  " context"                                                            NL
+  "-value"                                                              NL
+  "+new value"                                                          NL
+  ""                                                                    NL;
 
   /* ### Add edge cases like context lines stripped from leading whitespaces
    * ### that starts with 'Added: ', 'Deleted: ' or 'Modified: '. */
@@ -128,6 +199,53 @@ static const char *git_unidiff =
   "## -0,0 +1 ##"                                                       NL
   "+value"                                                              NL;
 
+  /* A unidiff containing diff symbols in the body of the hunks. */
+  static const char *diff_symbols_in_prop_unidiff =
+  "Index: iota"                                                         NL
+  "===================================================================" NL
+  "--- iota"                                                            NL
+  "+++ iota"                                                            NL
+  ""                                                                    NL
+  "Property changes on: iota"                                           NL
+  "___________________________________________________________________" NL
+  "Added: prop_add"                                                     NL
+  "## -0,0 +1,3 ##"                                                     NL
+  "+Added: bogus_prop"                                                  NL
+  "+## -0,0 +20 ##"                                                     NL
+  "+@@ -1,2 +0,0 @@"                                                    NL
+  "Deleted: prop_del"                                                   NL
+  "## -1,2 +0,0 ##"                                                     NL
+  "---- iota"                                                           NL
+  "-+++ iota"                                                           NL
+  "Modified: non-existent"                                              NL
+  "blah, just noise - no valid hunk header"                             NL
+  "Modified: prop_mod"                                                  NL
+  "## -1,4 +1,4 ##"                                                     NL
+  "-## -1,2 +1,2 ##"                                                    NL
+  "+## -1,3 +1,3 ##"                                                    NL
+  " ## -1,5 -0,0 ##"                                                    NL
+  " @@ -1,5 -0,0 @@"                                                    NL
+  " Modified: prop_mod"                                                 NL
+  "## -10,4 +10,4 ##"                                                   NL
+  " context"                                                            NL
+  " context"                                                            NL
+  " context"                                                            NL
+  "-## -0,0 +1 ##"                                                      NL
+  "+## -1,2 +1,4 ##"                                                    NL
+  ""                                                                    NL;
+
+  /* A unidiff containing paths with spaces. */
+  static const char *path_with_spaces_unidiff =
+  "diff --git a/path 1 b/path 1"                                        NL
+  "new file mode 100644"                                                NL
+  "diff --git a/path one 1 b/path one 1"                                NL
+  "new file mode 100644"                                                NL
+  "diff --git a/dir/ b/path b/dir/ b/path"                              NL
+  "new file mode 100644"                                                NL
+  "diff --git a/ b/path 1 b/ b/path 1"                                  NL
+  "new file mode 100644"                                                NL;
+
+
 /* Create a PATCH_FILE with name FNAME containing the contents of DIFF. */
 static svn_error_t *
 create_patch_file(apr_file_t **patch_file, const char *fname,
@@ -154,15 +272,18 @@ create_patch_file(apr_file_t **patch_fil
   return SVN_NO_ERROR;
 }
 
-/* Check that CONTENT equals what's inside EXPECTED. */
+/* Check that reading a line from HUNK equals what's inside EXPECTED.
+ * If ORIGINAL is TRUE, read the original hunk text; else, read the
+ * modified hunk text. */
 static svn_error_t *
-check_content(svn_stream_t *content, const char *expected, apr_pool_t *pool)
+check_content(svn_diff_hunk_t *hunk, svn_boolean_t original,
+              const char *expected, apr_pool_t *pool)
 {
   svn_stream_t *exp;
   svn_stringbuf_t *exp_buf;
-  svn_stringbuf_t *content_buf;
+  svn_stringbuf_t *hunk_buf;
   svn_boolean_t exp_eof;
-  svn_boolean_t content_eof;
+  svn_boolean_t hunk_eof;
 
   exp = svn_stream_from_string(svn_string_create(expected, pool), 
                                pool);
@@ -170,18 +291,23 @@ check_content(svn_stream_t *content, con
   while (TRUE)
   {
     SVN_ERR(svn_stream_readline(exp, &exp_buf, NL, &exp_eof, pool));
-    SVN_ERR(svn_stream_readline(content, &content_buf, NL, &content_eof,
-                                pool));
-    SVN_TEST_ASSERT(exp_eof == content_eof);
+    if (original)
+      SVN_ERR(svn_diff_hunk_readline_original_text(hunk, &hunk_buf, NULL,
+                                                   &hunk_eof, pool, pool));
+    else
+      SVN_ERR(svn_diff_hunk_readline_modified_text(hunk, &hunk_buf, NULL,
+                                                   &hunk_eof, pool, pool));
+       
+    SVN_TEST_ASSERT(exp_eof == hunk_eof);
     if (exp_eof)
       break;
-    if (strcmp(exp_buf->data, content_buf->data))
+    if (strcmp(exp_buf->data, hunk_buf->data))
       return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
                                "Expected '%s' but was '%s'", exp_buf->data,
-                               content_buf->data);
+                               hunk_buf->data);
   }
 
-  SVN_TEST_ASSERT(content_buf->len == 0);
+  SVN_TEST_ASSERT(hunk_buf->len == 0);
 
   return SVN_NO_ERROR;
 }
@@ -204,10 +330,8 @@ test_parse_unidiff(apr_pool_t *pool)
   for (i = 0; i < 2; i++)
     {
       svn_patch_t *patch;
-      svn_hunk_t *hunk;
+      svn_diff_hunk_t *hunk;
       apr_off_t pos;
-      svn_stream_t *original_text;
-      svn_stream_t *modified_text;
 
       svn_pool_clear(iterpool);
 
@@ -225,25 +349,12 @@ test_parse_unidiff(apr_pool_t *pool)
       SVN_TEST_ASSERT(! strcmp(patch->new_filename, "A/C/gamma"));
       SVN_TEST_ASSERT(patch->hunks->nelts == 1);
 
-      hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_hunk_t *);
-      if (reverse)
-        {
-          /* Hunk texts come out of the parser inverted,
-           * so this inverts them a second time. */
-          original_text = hunk->modified_text;
-          modified_text = hunk->original_text;
-        }
-      else
-        {
-          original_text = hunk->original_text;
-          modified_text = hunk->modified_text;
-        }
-
-      SVN_ERR(check_content(original_text,
+      hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+      SVN_ERR(check_content(hunk, ! reverse,
                             "This is the file 'gamma'." NL,
                             pool));
 
-      SVN_ERR(check_content(modified_text,
+      SVN_ERR(check_content(hunk, reverse,
                             "This is the file 'gamma'." NL
                             "some more bytes to 'gamma'" NL,
                             pool));
@@ -264,26 +375,13 @@ test_parse_unidiff(apr_pool_t *pool)
         }
       SVN_TEST_ASSERT(patch->hunks->nelts == 1);
 
-      hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_hunk_t *);
-      if (reverse)
-        {
-          /* Hunk texts come out of the parser inverted,
-           * so this inverts them a second time. */
-          original_text = hunk->modified_text;
-          modified_text = hunk->original_text;
-        }
-      else
-        {
-          original_text = hunk->original_text;
-          modified_text = hunk->modified_text;
-        }
-
-      SVN_ERR(check_content(original_text,
+      hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+      SVN_ERR(check_content(hunk, ! reverse,
                             "This is the file 'gamma'." NL
                             "some less bytes to 'gamma'" NL,
                             pool));
 
-      SVN_ERR(check_content(modified_text,
+      SVN_ERR(check_content(hunk, reverse,
                             "This is the file 'gamma'." NL,
                             pool));
 
@@ -300,7 +398,7 @@ test_parse_git_diff(apr_pool_t *pool)
 
   apr_file_t *patch_file;
   svn_patch_t *patch;
-  svn_hunk_t *hunk;
+  svn_diff_hunk_t *hunk;
   const char *fname = "test_parse_git_diff.patch";
 
   SVN_ERR(create_patch_file(&patch_file, fname, git_unidiff, pool));
@@ -327,13 +425,13 @@ test_parse_git_diff(apr_pool_t *pool)
   SVN_TEST_ASSERT(patch->operation == svn_diff_op_modified);
   SVN_TEST_ASSERT(patch->hunks->nelts == 1);
   
-  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_hunk_t *);
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
 
-  SVN_ERR(check_content(hunk->original_text,
+  SVN_ERR(check_content(hunk, TRUE,
                         "This is the file 'gamma'." NL,
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
+  SVN_ERR(check_content(hunk, FALSE,
                         "This is the file 'gamma'." NL
                         "some more bytes to 'gamma'" NL,
                         pool));
@@ -365,6 +463,141 @@ test_parse_git_diff(apr_pool_t *pool)
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_parse_git_tree_and_text_diff(apr_pool_t *pool)
+{
+  /* ### Should we check for reversed diffs? */
+
+  apr_file_t *patch_file;
+  svn_patch_t *patch;
+  svn_diff_hunk_t *hunk;
+  const char *fname = "test_parse_git_tree_and_text_diff.patch";
+
+  SVN_ERR(create_patch_file(&patch_file, fname, git_tree_and_text_unidiff,
+                            pool));
+
+  /* Parse a copied file with text modifications. */
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "iota"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "iota.copied"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_copied);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 1);
+  
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "This is the file 'iota'." NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "This is the file 'iota'." NL
+                        "some more bytes to 'iota'" NL,
+                        pool));
+
+  /* Parse a moved file with text modifications. */
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "A/mu"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "A/mu.moved"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_moved);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 1);
+  
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "This is the file 'mu'." NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "This is the file 'mu'." NL
+                        "some more bytes to 'mu'" NL,
+                        pool));
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "/dev/null"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "new"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_added);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 1);
+  
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "",
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "This is the file 'new'." NL,
+                        pool));
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "A/B/lambda"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "/dev/null"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_deleted);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 1);
+  
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "This is the file 'lambda'." NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "",
+                        pool));
+  return SVN_NO_ERROR;
+}
+
+/* Tests to parse non-valid git diffs. */
+static svn_error_t *
+test_bad_git_diff_headers(apr_pool_t *pool)
+{
+  apr_file_t *patch_file;
+  svn_patch_t *patch;
+  svn_diff_hunk_t *hunk;
+  const char *fname = "test_bad_git_diff_header.patch";
+
+  SVN_ERR(create_patch_file(&patch_file, fname, bad_git_diff_header,
+                            pool));
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "iota"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "iota.copied"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_copied);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 1);
+  
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "This is the file 'iota'." NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "This is the file 'iota'." NL
+                        "some more bytes to 'iota'" NL,
+                        pool));
+
+  return SVN_NO_ERROR;
+}
+
 /* Tests to parse a diff with three property changes, one is added, one is
  * modified and one is deleted. */
 static svn_error_t *
@@ -372,7 +605,8 @@ test_parse_property_diff(apr_pool_t *poo
 {
   apr_file_t *patch_file;
   svn_patch_t *patch;
-  svn_hunk_t *hunk;
+  svn_prop_patch_t *prop_patch;
+  svn_diff_hunk_t *hunk;
   apr_array_header_t *hunks;
   const char *fname = "test_parse_property_diff.patch";
 
@@ -386,44 +620,82 @@ test_parse_property_diff(apr_pool_t *poo
   SVN_TEST_ASSERT(! strcmp(patch->old_filename, "iota"));
   SVN_TEST_ASSERT(! strcmp(patch->new_filename, "iota"));
   SVN_TEST_ASSERT(patch->hunks->nelts == 0);
-  SVN_TEST_ASSERT(apr_hash_count(patch->property_hunks) == 3);
+  SVN_TEST_ASSERT(apr_hash_count(patch->prop_patches) == 3);
+
+  /* Check the deleted property */
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_del",
+                            APR_HASH_KEY_STRING);
+
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_deleted);
+  hunks = prop_patch->hunks;
+
+  SVN_TEST_ASSERT(hunks->nelts == 1);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "value" NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "",
+                        pool));
 
   /* Check the added property */
-  hunks = apr_hash_get(patch->property_hunks, "prop_add", APR_HASH_KEY_STRING);
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_add",
+                            APR_HASH_KEY_STRING);
+
+  SVN_TEST_ASSERT(!strcmp("prop_add", prop_patch->name));
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_added);
+  hunks = prop_patch->hunks;
+
   SVN_TEST_ASSERT(hunks->nelts == 1);
-  hunk = APR_ARRAY_IDX(hunks, 0 , svn_hunk_t *);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
 
-  SVN_ERR(check_content(hunk->original_text,
+  SVN_ERR(check_content(hunk, TRUE,
                         "",
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
+  SVN_ERR(check_content(hunk, FALSE,
                         "value" NL,
                         pool));
 
-  /* Check the deleted property */
-  hunks = apr_hash_get(patch->property_hunks, "prop_del", APR_HASH_KEY_STRING);
-  SVN_TEST_ASSERT(hunks->nelts == 1);
-  hunk = APR_ARRAY_IDX(hunks, 0 , svn_hunk_t *);
+  /* Check the modified property */
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_mod",
+                            APR_HASH_KEY_STRING);
 
-  SVN_ERR(check_content(hunk->original_text,
-                        "value" NL,
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_modified);
+  hunks = prop_patch->hunks;
+
+  SVN_TEST_ASSERT(hunks->nelts == 2);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "value" NL
+                        "context" NL
+                        "context" NL
+                        "context" NL,
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
-                        "",
+  SVN_ERR(check_content(hunk, FALSE,
+                        "new value" NL
+                        "context" NL
+                        "context" NL
+                        "context" NL,
                         pool));
 
-  /* Check the modified property */
-  hunks = apr_hash_get(patch->property_hunks, "prop_mod", APR_HASH_KEY_STRING);
-  SVN_TEST_ASSERT(hunks->nelts == 1);
-  hunk = APR_ARRAY_IDX(hunks, 0 , svn_hunk_t *);
+  hunk = APR_ARRAY_IDX(hunks, 1 , svn_diff_hunk_t *);
 
-  SVN_ERR(check_content(hunk->original_text,
+  SVN_ERR(check_content(hunk, TRUE,
+                        "context" NL
+                        "context" NL
+                        "context" NL
                         "value" NL,
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
+  SVN_ERR(check_content(hunk, FALSE,
+                        "context" NL
+                        "context" NL
+                        "context" NL
                         "new value" NL,
                         pool));
 
@@ -435,7 +707,8 @@ test_parse_property_and_text_diff(apr_po
 {
   apr_file_t *patch_file;
   svn_patch_t *patch;
-  svn_hunk_t *hunk;
+  svn_prop_patch_t *prop_patch;
+  svn_diff_hunk_t *hunk;
   apr_array_header_t *hunks;
   const char *fname = "test_parse_property_and_text_diff.patch";
 
@@ -450,36 +723,193 @@ test_parse_property_and_text_diff(apr_po
   SVN_TEST_ASSERT(! strcmp(patch->old_filename, "iota"));
   SVN_TEST_ASSERT(! strcmp(patch->new_filename, "iota"));
   SVN_TEST_ASSERT(patch->hunks->nelts == 1);
-  SVN_TEST_ASSERT(apr_hash_count(patch->property_hunks) == 1);
+  SVN_TEST_ASSERT(apr_hash_count(patch->prop_patches) == 1);
 
   /* Check contents of text hunk */
-  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_hunk_t *);
+  hunk = APR_ARRAY_IDX(patch->hunks, 0, svn_diff_hunk_t *);
 
-  SVN_ERR(check_content(hunk->original_text,
+  SVN_ERR(check_content(hunk, TRUE,
                         "This is the file 'iota'." NL,
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
+  SVN_ERR(check_content(hunk, FALSE,
                         "This is the file 'iota'." NL
                         "some more bytes to 'iota'" NL,
                         pool));
 
   /* Check the added property */
-  hunks = apr_hash_get(patch->property_hunks, "prop_add", APR_HASH_KEY_STRING);
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_add",
+                            APR_HASH_KEY_STRING);
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_added);
+
+  hunks = prop_patch->hunks;
   SVN_TEST_ASSERT(hunks->nelts == 1);
-  hunk = APR_ARRAY_IDX(hunks, 0 , svn_hunk_t *);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
 
-  SVN_ERR(check_content(hunk->original_text,
+  SVN_ERR(check_content(hunk, TRUE,
                         "",
                         pool));
 
-  SVN_ERR(check_content(hunk->modified_text,
+  SVN_ERR(check_content(hunk, FALSE,
                         "value" NL,
                         pool));
 
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_parse_diff_symbols_in_prop_unidiff(apr_pool_t *pool)
+{
+  svn_patch_t *patch;
+  apr_file_t *patch_file;
+  svn_prop_patch_t *prop_patch;
+  svn_diff_hunk_t *hunk;
+  apr_array_header_t *hunks;
+  const char *fname = "test_parse_diff_symbols_in_prop_unidiff.patch";
+
+  SVN_ERR(create_patch_file(&patch_file, fname, diff_symbols_in_prop_unidiff,
+                            pool));
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "iota"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "iota"));
+  SVN_TEST_ASSERT(patch->hunks->nelts == 0);
+  SVN_TEST_ASSERT(apr_hash_count(patch->prop_patches) == 3);
+
+  /* Check the added property */
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_add",
+                            APR_HASH_KEY_STRING);
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_added);
+
+  hunks = prop_patch->hunks;
+  SVN_TEST_ASSERT(hunks->nelts == 1);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "",
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "Added: bogus_prop" NL
+                        "## -0,0 +20 ##" NL
+                        "@@ -1,2 +0,0 @@" NL,
+                        pool));
+
+  /* Check the deleted property */
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_del",
+                            APR_HASH_KEY_STRING);
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_deleted);
+
+  hunks = prop_patch->hunks;
+  SVN_TEST_ASSERT(hunks->nelts == 1);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "--- iota" NL
+                        "+++ iota" NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "",
+                        pool));
+
+  /* Check the modified property */
+  prop_patch = apr_hash_get(patch->prop_patches, "prop_mod",
+                            APR_HASH_KEY_STRING);
+  SVN_TEST_ASSERT(prop_patch->operation == svn_diff_op_modified);
+  hunks = prop_patch->hunks;
+  SVN_TEST_ASSERT(hunks->nelts == 2);
+  hunk = APR_ARRAY_IDX(hunks, 0 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "## -1,2 +1,2 ##" NL
+                        "## -1,5 -0,0 ##" NL
+                        "@@ -1,5 -0,0 @@" NL
+                        "Modified: prop_mod" NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "## -1,3 +1,3 ##" NL
+                        "## -1,5 -0,0 ##" NL
+                        "@@ -1,5 -0,0 @@" NL
+                        "Modified: prop_mod" NL,
+                        pool));
+
+  hunk = APR_ARRAY_IDX(hunks, 1 , svn_diff_hunk_t *);
+
+  SVN_ERR(check_content(hunk, TRUE,
+                        "context" NL
+                        "context" NL
+                        "context" NL
+                        "## -0,0 +1 ##" NL,
+                        pool));
+
+  SVN_ERR(check_content(hunk, FALSE,
+                        "context" NL
+                        "context" NL
+                        "context" NL
+                        "## -1,2 +1,4 ##" NL,
+                        pool));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_git_diffs_with_spaces_diff(apr_pool_t *pool)
+{
+  apr_file_t *patch_file;
+  svn_patch_t *patch;
+  const char *fname = "test_git_diffs_with_spaces_diff.patch";
+
+  SVN_ERR(create_patch_file(&patch_file, fname, path_with_spaces_unidiff,
+                            pool));
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "path 1"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "path 1"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_added);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 0);
+  
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "path one 1"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "path one 1"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_added);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 0);
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, "dir/ b/path"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, "dir/ b/path"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_added);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 0);
+
+  SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file, 
+                                    FALSE, /* reverse */
+                                    FALSE, /* ignore_whitespace */ 
+                                    pool, pool));
+  SVN_TEST_ASSERT(patch);
+  SVN_TEST_ASSERT(! strcmp(patch->old_filename, " b/path 1"));
+  SVN_TEST_ASSERT(! strcmp(patch->new_filename, " b/path 1"));
+  SVN_TEST_ASSERT(patch->operation == svn_diff_op_added);
+  SVN_TEST_ASSERT(patch->hunks->nelts == 0);
+
+  return SVN_NO_ERROR;
+}
 /* ========================================================================== */
 
 struct svn_test_descriptor_t test_funcs[] =
@@ -487,11 +917,19 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_NULL,
     SVN_TEST_PASS2(test_parse_unidiff,
                    "test unidiff parsing"),
-    SVN_TEST_XFAIL2(test_parse_git_diff,
+    SVN_TEST_PASS2(test_parse_git_diff,
                     "test git unidiff parsing"),
+    SVN_TEST_PASS2(test_parse_git_tree_and_text_diff,
+                   "test git unidiff parsing of tree and text changes"),
+    SVN_TEST_XFAIL2(test_bad_git_diff_headers,
+                    "test badly formatted git diff headers"),
     SVN_TEST_PASS2(test_parse_property_diff,
                    "test property unidiff parsing"),
     SVN_TEST_PASS2(test_parse_property_and_text_diff,
                    "test property and text unidiff parsing"),
+    SVN_TEST_PASS2(test_parse_diff_symbols_in_prop_unidiff,
+                   "test property diffs with odd symbols"),
+    SVN_TEST_PASS2(test_git_diffs_with_spaces_diff,
+                   "test git diffs with spaces in paths"),
     SVN_TEST_NULL
   };

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_fs_fs/fs-pack-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_fs_fs/fs-pack-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_fs_fs/fs-pack-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_fs_fs/fs-pack-test.c Wed Sep 15 19:32:26 2010
@@ -80,12 +80,6 @@ write_format(const char *path,
                                   contents, strlen(contents),
                                   svn_io_file_del_none, pool));
 
-#ifdef WIN32
-      /* make the destination writable, but only on Windows, because
-         Windows does not let us replace read-only files. */
-      SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool));
-#endif /* WIN32 */
-
       /* rename the temp file as the real destination */
       SVN_ERR(svn_io_file_rename(path_tmp, path, pool));
     }

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_ra_local/ra-local-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_ra_local/ra-local-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_ra_local/ra-local-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_ra_local/ra-local-test.c Wed Sep 15 19:32:26 2010
@@ -55,7 +55,7 @@ make_and_open_local_repos(svn_ra_session
   SVN_ERR(svn_test__create_repos(&repos, repos_name, opts, pool));
   SVN_ERR(svn_ra_initialize(pool));
 
-  SVN_ERR(svn_test__current_directory_url(&url, repos_name, pool));
+  SVN_ERR(svn_uri_get_file_url_from_dirent(&url, repos_name, pool));
 
   SVN_ERR(svn_ra_open3(session,
                        url,
@@ -146,13 +146,6 @@ split_url_syntax(apr_pool_t *pool)
       (SVN_ERR_TEST_FAILED, NULL,
        "svn_ra_local__split_URL failed to catch bad URL (scheme)");
 
-  /* Use only single slash after scheme */
-  apr_err = try_split_url("file:/path/to/repos", pool);
-  if (apr_err != SVN_ERR_RA_ILLEGAL_URL)
-    return svn_error_create
-      (SVN_ERR_TEST_FAILED, NULL,
-       "svn_ra_local__split_URL failed to catch bad URL (slashes)");
-
   /* Use only a hostname, with no path */
   apr_err = try_split_url("file://hostname", pool);
   if (apr_err != SVN_ERR_RA_ILLEGAL_URL)
@@ -223,7 +216,7 @@ check_split_url(const char *repos_path,
   /* Create a filesystem and repository */
   SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, pool));
 
-  SVN_ERR(svn_test__current_directory_url(&root_url, repos_path, pool));
+  SVN_ERR(svn_uri_get_file_url_from_dirent(&root_url, repos_path, pool));
   if (in_repos_path)
     url = apr_pstrcat(pool, root_url, in_repos_path, NULL);
   else

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/dirent_uri-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/dirent_uri-test.c Wed Sep 15 19:32:26 2010
@@ -24,7 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef _MSC_VER
+#if defined(WIN32) || defined(__OS2__)
 #include <direct.h>
 #define getcwd _getcwd
 #define getdcwd _getdcwd
@@ -41,6 +41,11 @@
 
 #define SVN_EMPTY_PATH ""
 
+/* This check must match the check on top of dirent_uri.c */
+#if defined(WIN32) || defined(__CYGWIN__) || defined(__OS2__)
+#define SVN_USE_DOS_PATHS
+#endif
+
 #define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
 
 static svn_error_t *
@@ -57,7 +62,7 @@ test_dirent_is_root(apr_pool_t *pool)
     { "/foo/bar",      FALSE },
     { "/foo",          FALSE },
     { "",              FALSE },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/foo",        FALSE },
     { "X:/",           TRUE },
     { "X:foo",         FALSE }, /* Based on non absolute root */
@@ -66,11 +71,11 @@ test_dirent_is_root(apr_pool_t *pool)
     { "//srv/shr/fld", FALSE },
     { "//srv/s r",     TRUE },
     { "//srv/s r/fld", FALSE },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "/",             TRUE },
     { "/X:foo",        FALSE },
     { "/X:",           FALSE },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -145,7 +150,7 @@ test_dirent_is_absolute(apr_pool_t *pool
     { "foo/bar",       FALSE },
     { "foo",           FALSE },
     { "",              FALSE },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "/foo/bar",      FALSE },
     { "/foo",          FALSE },
     { "/",             FALSE },
@@ -157,13 +162,13 @@ test_dirent_is_absolute(apr_pool_t *pool
     { "//srv/shr/fld", TRUE },
     { "//srv/s r",     TRUE },
     { "//srv/s r/fld", TRUE },
-#else/* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "/foo/bar",      TRUE },
     { "/foo",          TRUE },
     { "/",             TRUE },
     { "X:/foo",        FALSE },
     { "X:/",           FALSE },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
     { "X:foo",         FALSE }, /* Not special on Posix, relative on Windows */
     { "X:foo/bar",     FALSE },
     { "X:",            FALSE },
@@ -269,7 +274,7 @@ test_dirent_join(apr_pool_t *pool)
     { SVN_EMPTY_PATH, "/abc", "/abc" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "/", "/", "/" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/", SVN_EMPTY_PATH, "X:/" },
     { "X:/", "abc", "X:/abc" },
     { "X:/", "/def", "X:/def" },
@@ -292,11 +297,11 @@ test_dirent_join(apr_pool_t *pool)
     { "aa", "A:", "A:" },
     { "aa", "A:file", "A:file"},
     { "A:", "/", "A:/" },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:abc", "X:/def", "X:abc/X:/def" },
     { "X:","abc", "X:/abc" },
     { "X:/abc", "X:/def", "X:/abc/X:/def" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(joins); i++ )
@@ -360,7 +365,7 @@ test_dirent_join(apr_pool_t *pool)
   TEST_MANY((pool, SVN_EMPTY_PATH, "/", SVN_EMPTY_PATH, NULL), "/");
   TEST_MANY((pool, SVN_EMPTY_PATH, SVN_EMPTY_PATH, "/", NULL), "/");
 
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
   TEST_MANY((pool, "X:/", "def", "ghi", NULL), "X:/def/ghi");
   TEST_MANY((pool, "abc", "X:/", "ghi", NULL), "X:/ghi");
   TEST_MANY((pool, "abc", "def", "X:/", NULL), "X:/");
@@ -389,12 +394,12 @@ test_dirent_join(apr_pool_t *pool)
   TEST_MANY((pool, "abcd", "/dir", "A:", "file", NULL), "A:file");
   TEST_MANY((pool, "abcd", "A:", "/dir", "file", NULL), "A:/dir/file");
 
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
   TEST_MANY((pool, "X:", "def", "ghi", NULL), "X:/def/ghi");
   TEST_MANY((pool, "X:", SVN_EMPTY_PATH, "ghi", NULL), "X:/ghi");
   TEST_MANY((pool, "X:", "def", SVN_EMPTY_PATH, NULL), "X:/def");
   TEST_MANY((pool, SVN_EMPTY_PATH, "X:", "ghi", NULL), "X:/ghi");
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
 
   /* ### probably need quite a few more tests... */
 
@@ -412,6 +417,8 @@ test_relpath_join(apr_pool_t *pool)
     { "a", "def", "a/def" },
     { "a", "d", "a/d" },
     { SVN_EMPTY_PATH, "abc", "abc" },
+    { "abc", SVN_EMPTY_PATH, "abc" },
+    { "", "", "" },
   };
 
   for (i = 0; i < COUNT_OF(joins); i++)
@@ -515,7 +522,7 @@ test_dirent_basename(apr_pool_t *pool)
     { "/", "" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "X:/abc", "abc" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:", "" },
     { "X:/", "" },
     { "X:abc", "abc" },
@@ -523,10 +530,10 @@ test_dirent_basename(apr_pool_t *pool)
     { "//srv/shr/fld", "fld" },
     { "//srv/shr/fld/subfld", "subfld" },
     { "//srv/s r/fld", "fld" },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:", "X:" },
     { "X:abc", "X:abc" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -633,7 +640,7 @@ test_dirent_dirname(apr_pool_t *pool)
     { "/", "/" },
     { SVN_EMPTY_PATH, SVN_EMPTY_PATH },
     { "X:abc/def", "X:abc" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/", "X:/" },
     { "X:/abc", "X:/" },
     { "X:abc", "X:" },
@@ -642,11 +649,11 @@ test_dirent_dirname(apr_pool_t *pool)
     { "//srv/shr/fld",  "//srv/shr" },
     { "//srv/shr/fld/subfld", "//srv/shr/fld" },
     { "//srv/s r/fld",  "//srv/s r" },
-#else  /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     /* on non-Windows platforms, ':' is allowed in pathnames */
     { "X:", "" },
     { "X:abc", "" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -776,7 +783,7 @@ test_dirent_canonicalize(apr_pool_t *poo
     { "X:",                   "X:" },
     { "X:foo",                "X:foo" },
     { "C:/folder/subfolder/file", "C:/folder/subfolder/file" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/",                  "X:/" },
     { "X:/./",                "X:/" },
     { "x:/",                  "X:/" },
@@ -793,7 +800,7 @@ test_dirent_canonicalize(apr_pool_t *poo
     { "//SERVER/SHare/",      "//server/SHare" },
     { "//srv/s r",            "//srv/s r" },
     { "//srv/s r/qq",         "//srv/s r/qq" },
-#endif /* WIN32 or Cygwin */
+#endif /* SVN_USE_DOS_PATHS */
   };
   int i;
 
@@ -963,15 +970,15 @@ test_uri_canonicalize(apr_pool_t *pool)
     { "s://d/c#",              "s://d/c%23" }, /* Escape schema separator */
     { "s://d/c($) .+?",        "s://d/c($)%20.+%3F" }, /* Test special chars */
     { "file:///C%3a/temp",     "file:///C:/temp" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "file:///c:/temp/repos", "file:///C:/temp/repos" },
     { "file:///c:/temp/REPOS", "file:///C:/temp/REPOS" },
     { "file:///C:/temp/REPOS", "file:///C:/temp/REPOS" },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "file:///c:/temp/repos", "file:///c:/temp/repos" },
     { "file:///c:/temp/REPOS", "file:///c:/temp/REPOS" },
     { "file:///C:/temp/REPOS", "file:///C:/temp/REPOS" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
   int i;
 
@@ -1036,7 +1043,7 @@ test_dirent_is_canonical(apr_pool_t *poo
     { "X:foo",                 TRUE },
     { "X:foo/",                FALSE },
     { "file with spaces",      TRUE },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/",                   TRUE },
     { "X:/foo",                TRUE },
     { "X:",                    TRUE },
@@ -1055,13 +1062,13 @@ test_dirent_is_canonical(apr_pool_t *poo
     { "//server/SHare",        TRUE },
     { "//SERVER/SHare",        FALSE },
     { "//srv/SH RE",           TRUE },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:/",                   FALSE },
     /* Some people use colons in their filenames. */
     { ":", TRUE },
     { ".:", TRUE },
     { "foo/.:", TRUE },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
   int i;
 
@@ -1262,15 +1269,15 @@ test_uri_is_canonical(apr_pool_t *pool)
     { "file:///folder/c#",      FALSE }, /* # needs escaping */
     { "file:///fld/with space", FALSE }, /* # needs escaping */
     { "file:///fld/c%23",       TRUE }, /* Properly escaped C# */
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "file:///c:/temp/repos", FALSE },
     { "file:///c:/temp/REPOS", FALSE },
     { "file:///C:/temp/REPOS", TRUE },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "file:///c:/temp/repos", TRUE },
     { "file:///c:/temp/REPOS", TRUE },
     { "file:///C:/temp/REPOS", TRUE },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
   int i;
 
@@ -1324,23 +1331,23 @@ test_dirent_split(apr_pool_t *pool)
     { "/",               "/",             "" },
     { "X:/foo/bar",      "X:/foo",        "bar" },
     { "X:foo/bar",       "X:foo",         "bar" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/",             "X:/",           "" },
     { "X:/foo",          "X:/",           "foo" },
     { "X:foo",           "X:",            "foo" },
     { "//srv/shr",       "//srv/shr",     "" },
     { "//srv/shr/fld",   "//srv/shr",     "fld" },
     { "//srv/s r",       "//srv/s r",     "" },
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:foo",           SVN_EMPTY_PATH,  "X:foo" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(paths); i++)
     {
       const char *dir, *base_name;
 
-      svn_dirent_split(paths[i][0], &dir, &base_name, pool);
+      svn_dirent_split(&dir, &base_name, paths[i][0], pool);
       if (strcmp(dir, paths[i][1]))
         {
           return svn_error_createf
@@ -1375,7 +1382,7 @@ test_relpath_split(apr_pool_t *pool)
     {
       const char *dir, *base_name;
 
-      svn_relpath_split(paths[i][0], &dir, &base_name, pool);
+      svn_relpath_split( &dir, &base_name, paths[i][0], pool);
       if (strcmp(dir, paths[i][1]))
         {
           return svn_error_createf
@@ -1414,7 +1421,7 @@ test_uri_split(apr_pool_t *pool)
     {
       const char *dir, *base_name;
 
-      svn_uri_split(paths[i][0], &dir, &base_name, pool);
+      svn_uri_split(&dir, &base_name, paths[i][0], pool);
       if (strcmp(dir, paths[i][1]))
         {
           return svn_error_createf
@@ -1461,7 +1468,7 @@ test_dirent_is_ancestor(apr_pool_t *pool
     { SVN_EMPTY_PATH,    SVN_EMPTY_PATH,  TRUE},
     { "/",               "/",             TRUE},
     { "X:foo",           "X:bar",         FALSE},
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "//srv/shr",       "//srv",         FALSE},
     { "//srv/shr",       "//srv/shr/fld", TRUE },
     { "//srv/s r",       "//srv/s r/fld", TRUE },
@@ -1473,10 +1480,10 @@ test_dirent_is_ancestor(apr_pool_t *pool
     { "X:/",             "X:/foo",        TRUE},
     { "X:",              "X:foo",         TRUE},
     { SVN_EMPTY_PATH,    "C:/",           FALSE},
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:",              "X:foo",         FALSE},
     { SVN_EMPTY_PATH,    "C:/",           TRUE},
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -1612,7 +1619,7 @@ test_dirent_skip_ancestor(apr_pool_t *po
     { "foo/bar",         "foo",             "foo"},
     { "/foo/bar",        "foo",             "foo"},
     { "/",               "bar/bla",         "bar/bla"},
-#ifdef WIN32
+#ifdef SVN_USE_DOS_PATHS
     { "A:/foo",          "A:/foo/bar",      "bar"},
     { "A:/foo",          "A:/foot",         "A:/foot"},
     { "A:/",             "A:/foo",          "foo"},
@@ -1750,7 +1757,7 @@ test_dirent_get_longest_ancestor(apr_poo
     { "/",              "/",               "/"},
     { "X:foo",          "Y:foo",           SVN_EMPTY_PATH},
     { "X:/folder1",     "Y:/folder2",      SVN_EMPTY_PATH},
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "X:/",            "X:/",             "X:/"},
     { "X:/foo/bar/A/D/H/psi", "X:/foo/bar/A/B", "X:/foo/bar/A" },
     { "X:/foo/bar/boo", "X:/foo/bar/baz/boz", "X:/foo/bar"},
@@ -1764,12 +1771,12 @@ test_dirent_get_longest_ancestor(apr_poo
     { "X:",             "X:foo",           "X:"},
     { "X:",             "X:/",             SVN_EMPTY_PATH},
     { "X:foo",          "X:bar",           "X:"},
-#else /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "X:/foo",         "X:",              "X:"},
     { "X:/folder1",     "X:/folder2",      "X:"},
     { "X:",             "X:foo",           SVN_EMPTY_PATH},
     { "X:foo",          "X:bar",           SVN_EMPTY_PATH},
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -1945,7 +1952,7 @@ test_dirent_is_child(apr_pool_t *pool)
     ".foo",
     "/",
     "foo2",
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     "//srv",
     "//srv2",
     "//srv/shr",
@@ -1960,7 +1967,7 @@ test_dirent_is_child(apr_pool_t *pool)
     "H:",
     "H:foo",
     "H:foo/baz",
-#endif /* Win32 and Cygwin */
+#endif /* SVN_USE_DOS_PATHS */
     };
 
   /* Maximum number of path[] items for all platforms */
@@ -1991,7 +1998,7 @@ test_dirent_is_child(apr_pool_t *pool)
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     /* //srv paths */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, "shr", "shr/fld", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -2024,7 +2031,7 @@ test_dirent_is_child(apr_pool_t *pool)
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "baz" },
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
-#endif /* Win32 and Cygwin */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   for (i = 0; i < COUNT_OF(paths); i++)
@@ -2233,10 +2240,10 @@ test_dirent_get_absolute(apr_pool_t *poo
   int i;
   const char *curdir;
   char buf[8192];
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
   const char *curdironc;
   char curdrive[3] = "C:";
-#endif /* WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
 
   struct {
     const char *path;
@@ -2245,7 +2252,7 @@ test_dirent_get_absolute(apr_pool_t *poo
     /* '%' will be replaced by the current working dir. */
     { "abc", "%/abc" },
     { SVN_EMPTY_PATH, "%" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     /* '@' will be replaced by the current working dir on C:\. */
     /* '$' will be replaced by the current drive */
     { "C:/", "C:/" },
@@ -2262,12 +2269,12 @@ test_dirent_get_absolute(apr_pool_t *poo
     { "//srv/shr",      "//srv/shr" },
     { "//srv/shr/fld",  "//srv/shr" },
     { "//srv/shr/fld/subfld", "//srv/shr/fld" }, */
-#else  /* WIN32 or Cygwin */
+#else /* !SVN_USE_DOS_PATHS */
     { "/abc", "/abc" },
     { "/x/abc", "/x/abc" },
     { "X:", "%/X:" },
     { "X:abc", "%/X:abc" },
-#endif /* non-WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
   };
 
   if (! getcwd(buf, sizeof(buf)))
@@ -2275,13 +2282,13 @@ test_dirent_get_absolute(apr_pool_t *poo
 
   curdir = svn_dirent_internal_style(buf, pool);
 
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
   if (! getdcwd(3, buf, sizeof(buf))) /* 3 stands for drive C: */
     return svn_error_create(SVN_ERR_BASE, NULL, "getdcwd() failed");
 
   curdironc = svn_dirent_internal_style(buf, pool);
   curdrive[0] = curdir[0];
-#endif /* WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
 
   for (i = 0 ; i < COUNT_OF(tests) ; i++ )
     {
@@ -2292,7 +2299,7 @@ test_dirent_get_absolute(apr_pool_t *poo
       expect_abs = expect;
       if (*expect == '%')
         expect_abs = apr_pstrcat(pool, curdir, expect + 1, NULL);
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
       if (*expect == '@')
         expect_abs = apr_pstrcat(pool, curdironc, expect + 1, NULL);
 
@@ -2301,7 +2308,7 @@ test_dirent_get_absolute(apr_pool_t *poo
 
       /* Remove double '/' when CWD was the root dir (E.g. C:/) */
       expect_abs = svn_dirent_canonicalize(expect_abs, pool);
-#endif /* WIN32 */
+#endif /* SVN_USE_DOS_PATHS */
 
       SVN_ERR(svn_dirent_get_absolute(&result, path, pool));
       if (strcmp(result, expect_abs))
@@ -2389,7 +2396,7 @@ test_dirent_condense_targets(apr_pool_t 
     { { "/dir", "/dir/file", NULL },         NULL,     { "", "file" } },
     { { "/dir1", "/dir2", NULL },            NULL,     { "dir1", "dir2" } },
     { { "dir1", "dir2", NULL },              NULL,     { "dir1", "dir2" } },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { {"C:/", "C:/zeta", NULL},              "C:/",    {"", "zeta"} },
     { {"C:/dir", "C:/dir/zeta", NULL},       "C:/dir", {"", "zeta"} },
     { {"C:/dir/omega", "C:/dir/zeta", NULL}, "C:/dir", {"omega", "zeta" } },
@@ -2518,7 +2525,7 @@ test_dirent_local_style(apr_pool_t *pool
   } tests[] = {
     { "",                     "." },
     { ".",                    "." },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "A:/",                 "A:\\" },
     { "A:/file",             "A:\\file" },
     { "a:/",                 "A:\\" },
@@ -2561,7 +2568,7 @@ test_relpath_local_style(apr_pool_t *poo
     { "",                     "." },
     { ".",                    "." },
     { "c:hi",                 "c:hi" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "dir/file",             "dir\\file" },
     { "a:/file",              "a:\\file" },
 #else
@@ -2598,7 +2605,7 @@ test_dirent_internal_style(apr_pool_t *p
     { "file",                "file" },
     { "dir/file",            "dir/file" },
     { "dir/file/./.",        "dir/file" },
-#if defined(WIN32) || defined(__CYGWIN__)
+#ifdef SVN_USE_DOS_PATHS
     { "A:\\",                "A:/" },
     { "A:\\file",            "A:/file" },
     { "A:file",              "A:file" },
@@ -2670,6 +2677,188 @@ test_relpath_internal_style(apr_pool_t *
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_dirent_from_file_url(apr_pool_t *pool)
+{
+  struct {
+    const char *url;
+    const char *result;
+  } tests[] = {
+    { "file://",                   "/" },
+    { "file:///dir",               "/dir" },
+    { "file:///dir/path",          "/dir/path" },
+    { "file://localhost",          "/" },
+    { "file://localhost/dir",      "/dir" },
+    { "file://localhost/dir/path", "/dir/path" },
+#ifdef SVN_USE_DOS_PATHS
+    { "file://server/share",       "//server/share" },
+    { "file://server/share/dir",   "//server/share/dir" },
+    { "file:///A:",                "A:/" },
+    { "file:///A:/dir",            "A:/dir" },
+    { "file:///A:dir",             "A:dir" },
+    { "file:///A%7C",              "A:/" },
+    { "file:///A%7C/dir",          "A:/dir" },
+    { "file:///A%7Cdir",           "A:dir" },
+#endif
+  };
+  int i;
+
+  for (i = 0; i < COUNT_OF(tests); i++)
+    {
+      const char *result;
+      
+      SVN_ERR(svn_uri_get_dirent_from_file_url(&result, tests[i].url, pool));
+
+      if (strcmp(result, tests[i].result))
+        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                 "svn_uri_get_dirent_from_file_url(\"%s\") "
+                                 "returned \"%s\" expected \"%s\"",
+                                 tests[i].url, result, tests[i].result);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_dirent_from_file_url_errors(apr_pool_t *pool)
+{
+  const char *bad_file_urls[] = {
+    /* error if scheme is not "file" */
+    "http://localhost/dir",
+    "file+ssh://localhost/dir",
+#ifndef SVN_USE_DOS_PATHS
+    "file://localhostwrongname/dir",  /* error if host name not "localhost" */
+#endif
+  };
+  int i;
+
+  for (i = 0; i < COUNT_OF(bad_file_urls); i++)
+    {
+      const char *result;
+      svn_error_t *err;
+
+      err = svn_uri_get_dirent_from_file_url(&result, bad_file_urls[i],
+                                             pool);
+
+      if (err == NULL)
+        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                 "svn_uri_get_dirent_from_file_url(\"%s\") "
+                                 "didn't return an error.",
+                                 bad_file_urls[i]);
+      svn_error_clear(err);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_file_url_from_dirent(apr_pool_t *pool)
+{
+  struct {
+    const char *dirent;
+    const char *result;
+  } tests[] = {
+#ifdef SVN_USE_DOS_PATHS
+    { "C:/file",                   "file:///C:/file" },
+    { "C:/",                       "file:///C:/" },
+    { "C:/File#$",                 "file:///C:/File%23$" },
+    /* We can't check these as svn_dirent_get_absolute() won't work
+       on shares that don't exist */
+    /*{ "//server/share",            "file://server/share" },
+    { "//server/share/file",       "file://server/share/file" },*/
+#else
+    { "/a/b",                      "file:///a/b" },
+    { "/a",                        "file:///a" },
+    { "/",                         "file:///" },
+    { "/File#$",                   "file:///File%23$" },
+#endif
+  };
+  int i;
+
+  for (i = 0; i < COUNT_OF(tests); i++)
+    {
+      const char *result;
+      
+      SVN_ERR(svn_uri_get_file_url_from_dirent(&result, tests[i].dirent,
+                                               pool));
+
+      if (strcmp(result, tests[i].result))
+        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                 "svn_uri_get_file_url_from_dirent(\"%s\") "
+                                 "returned \"%s\" expected \"%s\"",
+                                 tests[i].dirent, result, tests[i].result);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_dirent_is_under_root(apr_pool_t *pool)
+{
+  struct {
+    const char *base_path;
+    const char *path;
+    svn_boolean_t under_root;
+    const char *result;
+  } tests[] = {
+    { "/",        "/base",          FALSE},
+    { "/aa",      "/aa/bb",         FALSE},
+    { "/base",    "/base2",         FALSE},
+    { "/b",       "bb",             TRUE, "/b/bb"},
+    { "/b",       "../bb",          FALSE},
+    { "/b",       "r/./bb",         TRUE, "/b/r/bb"},
+    { "/b",       "r/../bb",        TRUE, "/b/bb"},
+    { "/b",       "r/../../bb",     FALSE},
+    { "/b",       "./bb",           TRUE, "/b/bb"},
+    { "/b",       ".",              TRUE, "/b"},
+    { "/b",       "",               TRUE, "/b"},
+    { "b",        "b",              TRUE, "b/b"},
+#ifdef SVN_USE_DOS_PATHS
+    { "C:/file",  "a\\d",           TRUE, "C:/file/a/d"},
+    { "C:/file",  "aa\\..\\d",      TRUE, "C:/file/d"},
+    { "C:/file",  "aa\\..\\..\\d",  FALSE},
+#else
+    { "C:/file",  "a\\d",           TRUE, "C:/file/a\\d"},
+    { "C:/file",  "aa\\..\\d",      TRUE, "C:/file/aa\\..\\d"},
+    { "C:/file",  "aa\\..\\..\\d",  TRUE, "C:/file/aa\\..\\..\\d"},
+#endif /* SVN_USE_DOS_PATHS */
+  };
+  int i;
+
+  for (i = 0; i < COUNT_OF(tests); i++)
+    {
+      svn_boolean_t under_root;
+      const char *result;
+      
+      SVN_ERR(svn_dirent_is_under_root(&under_root,
+                                       &result,
+                                       tests[i].base_path,
+                                       tests[i].path,
+                                       pool));
+
+      if (under_root != tests[i].under_root)
+        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                 "svn_dirent_is_under_root(..\"%s\", \"%s\"..)"
+                                 " returned %s expected %s.",
+                                 tests[i].base_path,
+                                 tests[i].path,
+                                 under_root ? "TRUE" : "FALSE",
+                                 tests[i].under_root ? "TRUE" : "FALSE");
+
+      if (under_root
+          && strcmp(result, tests[i].result) != 0)
+        return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+                                 "svn_dirent_is_under_root(..\"%s\", \"%s\"..)"
+                                 " found \"%s\" expected \"%s\".",
+                                 tests[i].base_path,
+                                 tests[i].path,
+                                 result,
+                                 tests[i].result);
+    }
+
+  return SVN_NO_ERROR;
+}
+
 
 /* The test table.  */
 
@@ -2762,5 +2951,13 @@ struct svn_test_descriptor_t test_funcs[
                    "test svn_dirent_internal_style"),
     SVN_TEST_PASS2(test_relpath_internal_style,
                    "test svn_relpath_internal_style"),
+    SVN_TEST_PASS2(test_dirent_from_file_url,
+                   "test svn_uri_get_dirent_from_file_url"),
+    SVN_TEST_PASS2(test_dirent_from_file_url_errors,
+                   "test svn_uri_get_dirent_from_file_url errors"),
+    SVN_TEST_PASS2(test_file_url_from_dirent,
+                   "test svn_uri_get_file_url_from_dirent"),
+    SVN_TEST_PASS2(test_dirent_is_under_root,
+                   "test svn_dirent_is_under_root"),
     SVN_TEST_NULL
   };

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/skel-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/skel-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/skel-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/skel-test.c Wed Sep 15 19:32:26 2010
@@ -184,9 +184,9 @@ put_implicit_length_byte(svn_stringbuf_t
       && ! skel_is_space(term)
       && ! skel_is_paren(term))
     abort();
-  svn_stringbuf_appendbytes(str, &byte, 1);
+  svn_stringbuf_appendbyte(str, byte);
   if (term != '\0')
-    svn_stringbuf_appendbytes(str, &term, 1);
+    svn_stringbuf_appendbyte(str, term);
 }
 
 
@@ -239,7 +239,7 @@ put_implicit_length_all_chars(svn_string
 
   svn_stringbuf_appendbytes(str, name, len);
   if (term != '\0')
-    svn_stringbuf_appendbytes(str, &term, 1);
+    svn_stringbuf_appendbyte(str, term);
 }
 
 
@@ -461,7 +461,7 @@ put_list_start(svn_stringbuf_t *str, cha
 
   svn_stringbuf_appendcstr(str, "(");
   for (i = 0; i < len; i++)
-    svn_stringbuf_appendbytes(str, &space, 1);
+    svn_stringbuf_appendbyte(str, space);
 }
 
 
@@ -476,7 +476,7 @@ put_list_end(svn_stringbuf_t *str, char 
     abort();
 
   for (i = 0; i < len; i++)
-    svn_stringbuf_appendbytes(str, &space, 1);
+    svn_stringbuf_appendbyte(str, space);
   svn_stringbuf_appendcstr(str, ")");
 }
 

Modified: subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/stream-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/stream-test.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/stream-test.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/tests/libsvn_subr/stream-test.c Wed Sep 15 19:32:26 2010
@@ -128,7 +128,7 @@ generate_test_bytes(int num_bytes, apr_p
 
   for (total = 0, repeat = repeat_iter = 1, c = 0; total < num_bytes; total++)
     {
-      svn_stringbuf_appendbytes(buffer, &c, 1);
+      svn_stringbuf_appendbyte(buffer, c);
 
       repeat_iter--;
       if (repeat_iter == 0)
@@ -307,142 +307,6 @@ test_stream_range(apr_pool_t *pool)
     return SVN_NO_ERROR;
 }
 
-/* An implementation of svn_io_line_filter_cb_t */
-static svn_error_t *
-line_filter(svn_boolean_t *filtered, const char *line, void *baton,
-            apr_pool_t *scratch_pool)
-{
-  *filtered = strchr(line, '!') != NULL;
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-test_stream_line_filter(apr_pool_t *pool)
-{
-  static const char *lines[4] = {"Not filtered.", "Filtered!",
-                                 "Not filtered either.", "End of the lines!"};
-  svn_string_t *string;
-  svn_stream_t *stream;
-  svn_stringbuf_t *line;
-  svn_boolean_t eof;
-
-  string = svn_string_createf(pool, "%s\n%s\n%s\n%s", lines[0], lines[1],
-                              lines[2], lines[3]);
-  stream = svn_stream_from_string(string, pool);
-
-  svn_stream_set_line_filter_callback(stream, line_filter);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, lines[0]);
-  /* line[1] should be filtered */
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, lines[2]);
-
-  /* The last line should also be filtered, and the resulting
-   * stringbuf should be empty. */
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_ASSERT(eof && svn_stringbuf_isempty(line));
-
-  return SVN_NO_ERROR;
-}
-
-/* An implementation of svn_io_line_transformer_cb_t */
-static svn_error_t *
-line_transformer(svn_stringbuf_t **buf, const char *line, void *baton,
-                 apr_pool_t *result_pool, apr_pool_t *scratch_pool)
-{
-  int i, len = strlen(line);
-  char *temp = apr_palloc(scratch_pool, len + 1 );
-
-  for (i = 0; i < len; i++)
-    {
-      temp[i] = line[len - 1 - i];
-    }
-
-  temp[len] = '\0';
-
-  *buf = svn_stringbuf_create(temp, result_pool);
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-test_stream_line_transformer(apr_pool_t *pool)
-{
-  static const char *lines[4] = {"gamma", "",
-                                 "iota", "!"};
-
-  static const char *inv_lines[4] = {"ammag", "",
-                                 "atoi", "!"};
-  svn_string_t *string;
-  svn_stream_t *stream;
-  svn_stringbuf_t *line;
-  svn_boolean_t eof;
-
-  string = svn_string_createf(pool, "%s\n%s\n%s\n%s", lines[0], lines[1],
-                              lines[2], lines[3]);
-
-  stream = svn_stream_from_string(string, pool);
-
-  svn_stream_set_line_transformer_callback(stream, line_transformer);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[0]);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[1]);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[2]);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[3]);
-
-  /* We should have reached eof and the stringbuf should be emtpy. */
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_ASSERT(eof && svn_stringbuf_isempty(line));
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
-test_stream_line_filter_and_transformer(apr_pool_t *pool)
-{
-  static const char *lines[4] = {"!gamma", "",
-                                 "iota", "!"};
-
-  static const char *inv_lines[4] = {"ammag", "",
-                                 "atoi", "!"};
-  svn_string_t *string;
-  svn_stream_t *stream;
-  svn_stringbuf_t *line;
-  svn_boolean_t eof;
-
-  string = svn_string_createf(pool, "%s\n%s\n%s\n%s", lines[0], lines[1],
-                              lines[2], lines[3]);
-
-  stream = svn_stream_from_string(string, pool);
-
-  svn_stream_set_line_filter_callback(stream, line_filter);
-
-  svn_stream_set_line_transformer_callback(stream, line_transformer);
-
-  /* Line one should be filtered. */
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[1]);
-
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_STRING_ASSERT(line->data, inv_lines[2]);
-
-  /* The last line should also be filtered, and the resulting
-   * stringbuf should be empty. */
-  svn_stream_readline(stream, &line, "\n", &eof, pool);
-  SVN_TEST_ASSERT(eof && svn_stringbuf_isempty(line));
-
-  return SVN_NO_ERROR;
-
-}
-
 static svn_error_t *
 test_stream_tee(apr_pool_t *pool)
 {
@@ -647,12 +511,6 @@ struct svn_test_descriptor_t test_funcs[
                    "test compressed streams"),
     SVN_TEST_PASS2(test_stream_range,
                    "test streams reading from range of file"),
-    SVN_TEST_PASS2(test_stream_line_filter,
-                   "test stream line filtering"),
-    SVN_TEST_PASS2(test_stream_line_transformer,
-                   "test stream line transforming"),
-    SVN_TEST_PASS2(test_stream_line_filter_and_transformer,
-                   "test stream line filtering and transforming"),
     SVN_TEST_PASS2(test_stream_tee,
                    "test 'tee' streams"),
     SVN_TEST_PASS2(test_stream_seek_file,