On Fri, Aug 05, 2011 at 06:22:03PM -0400, Dimitar Zlatkov wrote:
> Hi,
>
> Maybe I'm doing something wrong, but it seems to me that files that were added through svn merge should appear in the diff.
>
> For example, if I do this:
> > svn merge -r 1:2 http://url
> --- Merging r1 through r2 into '.':
> U my_updated_file.c
> A my_newly_added_file.c
>
> And then I do svn diff, I do not get a unified diff with the newly added file in it. I found this defect which talks about the same thing in svn 1.5: http://subversion.tigris.org/issues/show_bug.cgi?id=3261. The bug is marked as "works as expected" because the file is a copy.
>
> If it is a copy, then why did the merge command tell me the file was added (A)?
Subversion's user interface sometimes conflates "additions" with "copies"
because, under the hood, the two are very similar. You'll see an A for
copied files during 'svn merge'. But 'svn status' will show 'A +' for
them (the + indicates it is a copy).
Maybe this could be improved.
Do you have any ideas about how the output could be improved?
> Furthermore, if it is a copy, I should be able to svn add the file:
>
> > svn add my_newly_added_file.c
> svn: warning: 'my_newly_added_file.c' is already under version control
>
> So it is added apparently, but svn diff won't display it. If I revert the add and add it again, svn diff magically works and includes it. This behavior seems contradicting.
>
> I'm using svn 1.6.17 to do this. If there is an easier way to get a patch file out of my merge before I commit, that would be great. I also tried this on svn 1.7, and thankfully there is a --show-copies-as-adds which does this for me, but it seems like a hack and 1.7 is not stable yet.
>
I agree that this behaviour can be confusing based on how you expect
svn to behave. But it is by design.
Newly added files are always shown in the output of 'svn diff'.
For copies, svn diff shows how copies differ from the original.
This allows users to easily see whether a file derived from another
file (by svn copy + editing) differs from the original.
You want to see all the lines added to the copy, i.e. how the copy differs
from an empty file. This is a valid, but different, use case.
Unfortunately it is not supported in Subversion 1.6. Support for it is
added in 1.7 with the --show-copies-as-adds option.
I wouldn't call this a "hack". There are two valid use cases and the
new option allows you to select one of them.
I would recommend using a 1.7 client to generate your patches, like this:
svn diff --show-copies-as-adds -r100:101 https://svn.example.com/svn/trunk
You can continue using a 1.6 client for everything else.
If you want to see just the names of copied files which weren't modified
after being copied in the output of 'svn diff', try the new --git option
in 1.7. It will show something like the following for each such file:
Index: foo2
===================================================================
diff --git a/trunk/foo b/trunk/foo2
copy from trunk/foo
copy to trunk/foo2
Received on 2011-08-07 14:23:14 CEST