You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/08/28 15:48:22 UTC

svn commit: r990363 - in /subversion/trunk/subversion: libsvn_wc/diff.c tests/cmdline/diff_tests.py

Author: stsp
Date: Sat Aug 28 13:48:22 2010
New Revision: 990363

URL: http://svn.apache.org/viewvc?rev=990363&view=rev
Log:
Make copies modified after being copied show up correctly in git diffs.

* subversion/tests/cmdline/diff_tests.py
  (make_git_diff_header): In git diff headers for copies with modifications,
   show the REPOS_RELPATH, which is relative to the repository root,
   not the PATH_AS_SHOWN which comes from the command line.
  (diff_git_format_wc_wc): Expand test to cover copies with modifications.

* subversion/libsvn_wc/diff.c
  (file_diff): Move the MODIFIED local variable and related calls back into
   a tighter scope, as we don't need it elsewhere anymore.
   When generating git diffs, always report copies via the file_added()
   callback, never through the file_changed() one. We used to show copies
   with modifications via file_changed(), but that does not cause git diff
   copy headers to be generated.

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

Modified: subversion/trunk/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/diff.c?rev=990363&r1=990362&r2=990363&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/diff.c (original)
+++ subversion/trunk/subversion/libsvn_wc/diff.c Sat Aug 28 13:48:22 2010
@@ -567,7 +567,6 @@ file_diff(struct dir_baton *db,
   svn_boolean_t have_base;
   svn_wc__db_status_t base_status;
   const char *local_abspath;
-  svn_boolean_t modified;
 
   SVN_ERR_ASSERT(! eb->use_text_base);
 
@@ -662,23 +661,19 @@ file_diff(struct dir_baton *db,
         }
     }
 
-  SVN_ERR(svn_wc__internal_text_modified_p(&modified, eb->db,
-                                           local_abspath, FALSE, TRUE,
-                                           pool));
-
  /* Now deal with showing additions, or the add-half of replacements.
   * If the item is schedule-add *with history*, then we usually want
   * to see the usual working vs. text-base comparison, which will show changes
   * made since the file was copied.  But in case we're showing copies as adds,
   * we need to compare the copied file to the empty file. If we're doing a git
-  * diff, and the file was copied but not modified, we need to report the file
-  * as added and diff it against the text base (empty diff), so that a "copied"
-  * git diff header can be generated for it. */
+  * diff, and the file was copied, we need to report the file as added and
+  * diff it against the text base, so that a "copied" git diff header, and
+  * possibly a diff against the copy source, will be generated for it. */
   if ((! replaced && status == svn_wc__db_status_added) ||
      (replaced && ! eb->ignore_ancestry) ||
      ((status == svn_wc__db_status_copied ||
        status == svn_wc__db_status_moved_here) &&
-         (eb->show_copies_as_adds || (eb->use_git_diff_format && ! modified))))
+         (eb->show_copies_as_adds || eb->use_git_diff_format)))
     {
       const char *translated = NULL;
       const char *working_mimetype;
@@ -705,7 +700,8 @@ file_diff(struct dir_baton *db,
       SVN_ERR(eb->callbacks->file_added(NULL, NULL, NULL, NULL, path,
                                         (! eb->show_copies_as_adds &&
                                          eb->use_git_diff_format &&
-                                         ! modified) ? textbase : empty_file,
+                                         status != svn_wc__db_status_added) ?
+                                          textbase : empty_file,
                                         translated,
                                         0, revision,
                                         NULL,
@@ -723,9 +719,12 @@ file_diff(struct dir_baton *db,
       const char *working_mimetype;
       apr_hash_t *workingprops;
       apr_array_header_t *propchanges;
+      svn_boolean_t modified;
 
       /* Here we deal with showing pure modifications. */
-
+      SVN_ERR(svn_wc__internal_text_modified_p(&modified, eb->db,
+                                               local_abspath, FALSE, TRUE,
+                                               pool));
       if (modified)
         {
           /* Note that this might be the _second_ time we translate

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=990363&r1=990362&r2=990363&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Sat Aug 28 13:48:22 2010
@@ -113,7 +113,7 @@ def make_git_diff_header(target_path, re
     if text_changes:
       output.extend([
         "--- a/" + copyfrom_path + src_label + "\t(" + old_tag + ")\n",
-        "+++ b/" + path_as_shown + "\t(" + new_tag + ")\n"
+        "+++ b/" + repos_relpath + "\t(" + new_tag + ")\n"
       ])
   elif mv:
     return [
@@ -3368,12 +3368,16 @@ def diff_git_format_wc_wc(sbox):
   new_path = os.path.join(wc_dir, 'new')
   lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')
   lambda_copied_path = os.path.join(wc_dir, 'A', 'B', 'lambda_copied')
+  alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
+  alpha_copied_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha_copied')
 
   svntest.main.file_append(iota_path, "Changed 'iota'.\n")
   svntest.main.file_append(new_path, "This is the file 'new'.\n")
   svntest.main.run_svn(None, 'add', new_path)
   svntest.main.run_svn(None, 'rm', mu_path)
   svntest.main.run_svn(None, 'cp', lambda_path, lambda_copied_path)
+  svntest.main.run_svn(None, 'cp', alpha_path, alpha_copied_path)
+  svntest.main.file_append(alpha_copied_path, "This is a copy of 'alpha'.\n")
 
   ### We're not testing moved paths
 
@@ -3382,7 +3386,14 @@ def diff_git_format_wc_wc(sbox):
                                          "revision 1", "working copy",
                                          copyfrom_path="A/B/lambda", cp=True,
                                          text_changes=False) \
-  + make_git_diff_header(mu_path, "A/mu", "revision 1", 
+  + make_git_diff_header(alpha_copied_path, "A/B/E/alpha_copied",
+                         "revision 0", "working copy",
+                         copyfrom_path="A/B/E/alpha", cp=True,
+                         text_changes=True) + [
+    "@@ -1 +1,2 @@\n",
+    " This is the file 'alpha'.\n",
+    "+This is a copy of 'alpha'.\n",
+  ] + make_git_diff_header(mu_path, "A/mu", "revision 1", 
                                          "working copy", 
                                          delete=True) + [
     "@@ -1 +0,0 @@\n",