subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1512154 - in /subversion/branches/1.7.x-issue4408/subversion: libsvn_client/repos_diff_summarize.c tests/cmdline/diff_tests.py
Date Fri, 09 Aug 2013 06:38:27 GMT
Author: breser
Date: Fri Aug  9 06:38:26 2013
New Revision: 1512154

URL: http://svn.apache.org/r1512154
Log:
Fix Issue #4408: diff --summarize includes duplicate path elements.

The path provided to the summarize_function needs to be relative to the target.
Most of the time the target is "" but if a path doesn't exist on one side
of the diff (add or delete) then the root of the editor drive is moved outside
the target and the target gets duplicated in the output.

This issue is fixed on 1.8.x and newer as diff --summarize has a new and
different implementation.  That implementation is not appropriate to backport
as it adds new features.  Also note that 1.8.x+ already has tests for these
cases.

* subversion/libsvn_client/repos_diff_summarize.c
  (create_item_baton): Use svn_relpath_skip_ancestor instead of the hack added
    to fix Issue #2765.
  (diff_deleted_dir, delete_entry): Skip the target.

* subversion/tests/cmdline/diff_tests.py
  (basic_diff_summarize): Add tests for a newly added file and dir.
  

Modified:
    subversion/branches/1.7.x-issue4408/subversion/libsvn_client/repos_diff_summarize.c
    subversion/branches/1.7.x-issue4408/subversion/tests/cmdline/diff_tests.py

Modified: subversion/branches/1.7.x-issue4408/subversion/libsvn_client/repos_diff_summarize.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4408/subversion/libsvn_client/repos_diff_summarize.c?rev=1512154&r1=1512153&r2=1512154&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4408/subversion/libsvn_client/repos_diff_summarize.c (original)
+++ subversion/branches/1.7.x-issue4408/subversion/libsvn_client/repos_diff_summarize.c Fri
Aug  9 06:38:26 2013
@@ -93,14 +93,11 @@ create_item_baton(struct edit_baton *edi
   struct item_baton *b = apr_pcalloc(pool, sizeof(*b));
 
   b->edit_baton = edit_baton;
-  /* Issue #2765: b->path is supposed to be relative to the target.
-     If the target is a file, just use an empty path.  This way the
-     receiver can just concatenate this path to the original path
-     without doing any extra checks. */
-  if (node_kind == svn_node_file && strcmp(path, edit_baton->target) == 0)
-    b->path =  "";
-  else
-    b->path = apr_pstrdup(pool, path);
+  /* Issues #2765 & #4408: b->path is supposed to be relative to the target.
+     This way the receiver can just concatenate this path to the original
+     path without doing any extra checks. */
+  b->path = apr_pstrdup(pool,
+                        svn_relpath_skip_ancestor(edit_baton->target, path));
   b->node_kind = node_kind;
   b->item_pool = pool;
 
@@ -198,7 +195,8 @@ diff_deleted_dir(const char *dir,
 
       sum = apr_pcalloc(iterpool, sizeof(*sum));
       sum->summarize_kind = svn_client_diff_summarize_kind_deleted;
-      sum->path = path;
+      /* Issue #4408: sum->path should be relative to target. */
+      sum->path = svn_relpath_skip_ancestor(eb->target, path);
       sum->node_kind = kind;
 
       SVN_ERR(eb->summarize_func(sum,
@@ -240,7 +238,8 @@ delete_entry(const char *path,
 
   sum = apr_pcalloc(pool, sizeof(*sum));
   sum->summarize_kind = svn_client_diff_summarize_kind_deleted;
-  sum->path = path;
+  /* Issue #4408: sum->path should be relative to target. */
+  sum->path = svn_relpath_skip_ancestor(eb->target, path);
   sum->node_kind = kind;
 
   SVN_ERR(eb->summarize_func(sum, eb->summarize_func_baton, pool));

Modified: subversion/branches/1.7.x-issue4408/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4408/subversion/tests/cmdline/diff_tests.py?rev=1512154&r1=1512153&r2=1512154&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4408/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/branches/1.7.x-issue4408/subversion/tests/cmdline/diff_tests.py Fri Aug  9
06:38:26 2013
@@ -2677,6 +2677,30 @@ def basic_diff_summarize(sbox):
   svntest.actions.run_and_verify_diff_summarize(expected_reverse_diff,
                                                 wc_dir, '-c-3')
 
+  # Get the differences between a newly added file 
+  expected_diff = svntest.wc.State(wc_dir, {
+    'newfile': Item(status='A '),
+    })
+  expected_reverse_diff = svntest.wc.State(wc_dir, {
+    'newfile': Item(status='D '),
+    })
+  svntest.actions.run_and_verify_diff_summarize(expected_diff,
+                                                p('newfile'), '-c3')
+  svntest.actions.run_and_verify_diff_summarize(expected_reverse_diff,
+                                                p('newfile'), '-c-3')
+
+  # Get the differences between a newly added dir 
+  expected_diff = svntest.wc.State(wc_dir, {
+    'P': Item(status='A '),
+    })
+  expected_reverse_diff = svntest.wc.State(wc_dir, {
+    'P': Item(status='D '),
+    })
+  svntest.actions.run_and_verify_diff_summarize(expected_diff,
+                                                p('P'), '-c3')
+  svntest.actions.run_and_verify_diff_summarize(expected_reverse_diff,
+                                                p('P'), '-c-3')
+
 #----------------------------------------------------------------------
 def diff_weird_author(sbox):
   "diff with svn:author that has < in it"



Mime
View raw message