Hi SVN developers,

I noticed an issue which prevents the 'post-review' tool from ReviewBoard 
(http://www.reviewboard.org) from working with Subversion 1.7.x and trunk 
(1.8.0-dev).

This post-review tool uses external diff command to generate a diff file. With 
Subversion 1.7 and 1.8, using external diff tool results in an extra "Index:" 
header being printed. Here is a test case:

[[[
repo=/tmp/repo.test
wc=/tmp/wc.test

svnadmin create $repo
svn mkdir -m "create subdir" file://$repo/dir1
svn co file://$repo $wc
cd $wc

echo hi > dir1/file2
svn add dir1/file2
svn ps foo:bar baz dir1/file2
svn mv dir1 dir2
svn diff --diff-cmd=diff dir2 > output.diff
]]]

It produces the following diff file:
[[[
Index: dir2/file2
===================================================================
--- dir2/file2  (revision 0)
+++ dir2/file2  (working copy)
@@ -0,0 +1 @@
+hi
Index: dir2/file2
===================================================================
--- dir2/file2  (revision 1)
+++ dir2/file2  (working copy)

Property changes on: dir2/file2
___________________________________________________________________
Added: foo:bar
## -0,0 +1 ##
+baz
\ No newline at end of property
]]]

Not only there are two "Index:" headers printed, but the second one is 
incorrect: it refers to dir2/file2 as being present in revision 1. The post-
review tool, seeing this header, fails to find the origin of dir2/file2 in 
revision 1 and produces an error.

The reason is that the branch in diff_content_changed() that invokes an 
external diff tool does not mark the path as visited even though it emits the 
"Index:" header. Marking it as visited is sufficient, as the header is 
incorrect only if the file is added - in which case, one of the branches in 
diff_content_changed() is going to output the diff (diff_cmd_baton-
>force_empty is set for added files). Therefore, diff_prop_changed() will 
never output "Index:" header for added files.

Patch attached.

[[[
* subversion/libsvn_client/diff.c:
  (diff_content_changed): Mark path as visited if diffed by external tool.
]]]

Regards,
Alexey.
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c	(revision 1379251)
+++ subversion/libsvn_client/diff.c	(working copy)
@@ -1044,6 +1044,9 @@ diff_content_changed(const char *path,
                                        subpool, subpool));
       SVN_ERR(svn_stream_copy3(stream, svn_stream_disown(errstream, subpool),
                                NULL, NULL, subpool));
+
+      /* We have a printed a diff for this path, mark it as visited. */
+      mark_path_as_visited(diff_cmd_baton, path);
     }
   else   /* use libsvn_diff to generate the diff  */
     {

Reply via email to