Author: kameshj
Date: Fri Dec  3 14:36:33 2010
New Revision: 1041839

URL: http://svn.apache.org/viewvc?rev=1041839&view=rev
Log:
Follow-up to r1041068.

In r1041068 I removed "." as the default path for "" to fix assertion error.
This change is not consistent with our current behaviour(<1.6.x).

In this commit I am reinstating the "." as the
default path for ""(Revert r1041068.)
And move default assignment of "." when path is "", after the functions
that are not happy about "." are called.
One optimization of avoiding recomputing 'path relative to repos_root' as one
of the callers already has it computed.
I do this optimization in this commit as that makes my movement of path="."
assignment easier otherwise I would still get the assert error.

* subversion/libsvn_client/diff.c
 (print_git_diff_header): Caller 'display_prop_diffs' has already computed
  the path relative to repos_root. So no need to do it again here.
 (display_prop_diffs): Fix the call to 'print_git_diff_header' as per
  above change.
 (diff_content_changed): Compute path relative to repos path as 
  print_git_diff_header expects it.

* subversion/tests/cmdline/diff_tests.py
 (diff_with_depth): Revert r1041068.
 (diff_git_with_props_on_dir): Fix it to accept "." for "".

* subversion/tests/cmdline/depth_tests.py
 (diff_in_depthy_wc): Revert r1041068.

Found by: stsp

Modified:
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/tests/cmdline/depth_tests.py
    subversion/trunk/subversion/tests/cmdline/diff_tests.py

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1041839&r1=1041838&r2=1041839&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Fri Dec  3 14:36:33 2010
@@ -448,7 +448,7 @@ print_git_diff_header_modified(svn_strea
 
 /* Print a git diff header showing the OPERATION to the stream OS using
  * HEADER_ENCODING. Return suitable diff labels for the git diff in *LABEL1
- * and *LABEL2. PATH is the path being diffed, ORIG_TARGET1 and ORIG_TARGET2
+ * and *LABEL2. REPOS_RELPATH1 and REPOS_RELPATH2 are relative to reposroot.
  * are the paths passed to the original diff command. REV1 and REV2 are
  * revisions being diffed. COPYFROM_PATH indicates where the diffed item
  * was copied from. RA_SESSION and WC_CTX are used to adjust paths in the
@@ -460,9 +460,8 @@ static svn_error_t *
 print_git_diff_header(svn_stream_t *os,
                       const char **label1, const char **label2,
                       svn_diff_operation_kind_t operation,
-                      const char *path,
-                      const char *path1,
-                      const char *path2,
+                      const char *repos_relpath1,
+                      const char *repos_relpath2,
                       svn_revnum_t rev1,
                       svn_revnum_t rev2,
                       const char *copyfrom_path,
@@ -472,18 +471,6 @@ print_git_diff_header(svn_stream_t *os,
                       const char *wc_root_abspath,
                       apr_pool_t *scratch_pool)
 {
-  const char *repos_relpath1;
-  const char *repos_relpath2;
-
-  SVN_ERR(adjust_relative_to_repos_root(&repos_relpath1, path, path1,
-                                        ra_session, wc_ctx,
-                                        wc_root_abspath,
-                                        scratch_pool));
-  SVN_ERR(adjust_relative_to_repos_root(&repos_relpath2, path, path2,
-                                        ra_session, wc_ctx,
-                                        wc_root_abspath,
-                                        scratch_pool));
-
   if (operation == svn_diff_op_deleted)
     {
       SVN_ERR(print_git_diff_header_deleted(os, header_encoding,
@@ -586,6 +573,10 @@ display_prop_diffs(const apr_array_heade
                                             pool));
     }
 
+  /* If we're creating a diff on the wc root, path would be empty. */
+  if (path[0] == '\0')
+    path = apr_psprintf(pool, ".");
+
   if (show_diff_header)
     {
       const char *label1;
@@ -614,9 +605,8 @@ display_prop_diffs(const apr_array_heade
 
           os = svn_stream_from_aprfile2(file, TRUE, pool);
           SVN_ERR(print_git_diff_header(os, &label1, &label2,
-                                        svn_diff_op_modified, path,
-                                        orig_path1, orig_path2,
-                                        rev1, rev2, NULL,
+                                        svn_diff_op_modified,
+                                        path1, path2, rev1, rev2, NULL,
                                         encoding, ra_session, wc_ctx,
                                         wc_root_abspath, pool));
           SVN_ERR(svn_stream_close(os));
@@ -985,16 +975,25 @@ diff_content_changed(const char *path,
                    path, equal_string));
 
           if (diff_cmd_baton->use_git_diff_format)
-            SVN_ERR(print_git_diff_header(os, &label1, &label2, operation,
-                                          path, diff_cmd_baton->orig_path_1,
-                                          diff_cmd_baton->orig_path_2,
-                                          rev1, rev2,
-                                          copyfrom_path,
-                                          diff_cmd_baton->header_encoding,
-                                          diff_cmd_baton->ra_session,
-                                          diff_cmd_baton->wc_ctx,
-                                          diff_cmd_baton->wc_root_abspath,
-                                          subpool));
+            {
+              const char *tmp_path1, *tmp_path2;
+              SVN_ERR(adjust_relative_to_repos_root(
+                         &tmp_path1, path, diff_cmd_baton->orig_path_1,
+                         diff_cmd_baton->ra_session, diff_cmd_baton->wc_ctx,
+                         diff_cmd_baton->wc_root_abspath, subpool));
+              SVN_ERR(adjust_relative_to_repos_root(
+                         &tmp_path2, path, diff_cmd_baton->orig_path_2,
+                         diff_cmd_baton->ra_session, diff_cmd_baton->wc_ctx,
+                         diff_cmd_baton->wc_root_abspath, subpool));
+              SVN_ERR(print_git_diff_header(os, &label1, &label2, operation,
+                                            tmp_path1, tmp_path2, rev1, rev2,
+                                            copyfrom_path,
+                                            diff_cmd_baton->header_encoding,
+                                            diff_cmd_baton->ra_session,
+                                            diff_cmd_baton->wc_ctx,
+                                            diff_cmd_baton->wc_root_abspath,
+                                            subpool));
+            }
 
           /* Output the actual diff */
           if (svn_diff_contains_diffs(diff) || diff_cmd_baton->force_empty)

Modified: subversion/trunk/subversion/tests/cmdline/depth_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/depth_tests.py?rev=1041839&r1=1041838&r2=1041839&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/depth_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/depth_tests.py Fri Dec  3 
14:36:33 2010
@@ -1062,12 +1062,12 @@ def diff_in_depthy_wc(sbox):
     "@@ -1 +1 @@\n",
     "-new text\n",
     "+This is the file 'iota'.\n",
-    "Index: \n",
+    "Index: .\n",
     "===================================================================\n",
-    "--- \t(revision 2)\n",
-    "+++ \t(working copy)\n",
+    "--- .\t(revision 2)\n",
+    "+++ .\t(working copy)\n",
     "\n",
-    "Property changes on: \n",
+    "Property changes on: .\n",
     "___________________________________________________________________\n",
     "Deleted: foo\n",
     "## -1 +0,0 ##\n",

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=1041839&r1=1041838&r2=1041839&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Fri Dec  3 14:36:33 
2010
@@ -2868,7 +2868,7 @@ def diff_with_depth(sbox):
 
   diff = [
     "\n",
-    "Property changes on: \n",
+    "Property changes on: .\n",
     "___________________________________________________________________\n",
     "Added: foo1\n",
     "## -0,0 +1 ##\n",
@@ -2892,7 +2892,7 @@ def diff_with_depth(sbox):
     "## -0,0 +1 ##\n",
     "+bar4\n"]
 
-  dot_header = make_diff_header("", "revision 1", "working copy")
+  dot_header = make_diff_header(".", "revision 1", "working copy")
   iota_header = make_diff_header('iota', "revision 1", "working copy")
   A_header = make_diff_header('A', "revision 1", "working copy")
   B_header = make_diff_header(B_path, "revision 1", "working copy")
@@ -2939,7 +2939,7 @@ def diff_with_depth(sbox):
   svntest.actions.run_and_verify_svn(None, None, [],
                                      'ci', '-m', '')
 
-  dot_header = make_diff_header("", "revision 1", "revision 2")
+  dot_header = make_diff_header(".", "revision 1", "revision 2")
   iota_header = make_diff_header('iota', "revision 1", "revision 2")
   A_header = make_diff_header('A', "revision 1", "revision 2")
   B_header = make_diff_header(B_path, "revision 1", "revision 2")
@@ -3011,12 +3011,12 @@ def diff_with_depth(sbox):
     "## -1 +1 ##\n",
     "-bar2\n",
     "+baz2\n",
-    "Index: \n",
+    "Index: .\n",
     "===================================================================\n",
-    "--- \t(revision 2)\n",
-    "+++ \t(working copy)\n",
+    "--- .\t(revision 2)\n",
+    "+++ .\t(working copy)\n",
     "\n",
-    "Property changes on: \n",
+    "Property changes on: .\n",
     "___________________________________________________________________\n",
     "Modified: foo1\n",
     "## -1 +1 ##\n",
@@ -3735,7 +3735,7 @@ def diff_git_with_props_on_dir(sbox):
 
   was_cwd = os.getcwd()
   os.chdir(wc_dir)
-  expected_output = make_git_diff_header("", "", "revision 1",
+  expected_output = make_git_diff_header(".", "", "revision 1",
                                          "revision 2",
                                          add=False, text_changes=False) + [
       "\n",


Reply via email to