views:

280

answers:

2

Given: an SVN repository, a bin directory inside it and a script.pl inside this bin. Some revisions ago, bin and script.pl has been added to the repository in one commit. Since then, some revisions has been applied to script.pl.

Needed: a diff command which would return a complete diff for script.pl from zero to HEAD, i.e. a diff with all lines added.

Background: this diff is needed for code review, for feeding to ReviewBoard

Problem: svn diff with -r X:HEAD (X being the first revision of script.pl) produces a diff between the first version and HEAD while -r X-1:HEAD tell me the file script.pl is unknown in the revision X-1, which is actually correct. However, I can't find a proper solution which would include the diff from an empty file. I also can't diff the bin directory, since it has been added in the same commit as script.pl

Solution: ?

A: 

From the top of my head:

svn diff -r X-1:HEAD FILENAME@X

The filename isn't a unique key over time, but filename@revision is.

troelskn
Looked promising, but sadly: svn: Unable to find repository location for `script.pl` in revision X-1
rassie
Yeah, just tried it out and it doesn't work.
troelskn
A: 

Wait, you want a diff between the current (HEAD) version of script.pl and the empty file? You don't need a diff for that, because the diff would just be all the lines of the current script.pl with plusses in front of them. Exciting, no?

If you really need it in diff form, Why not just do this?

$ touch EMPTYFILE  # creates a new, empty file
$ diff -u EMPTYFILE script.pl > script.pl.diff

... or the local equivalent, should you be stuck with a less capable system.

bendin
Let's put it this way: touching and diffing is a hack. Doing this stuff with Subversion pure was the actual intention of the question -- especially because I'd like to use ReviewBoard which makes diffs itself using Subversion. I wondered why Subversion is unable to produce a proper diff and assumed I'm dumb, but it turns out it's Subversion and not me who is a bit under-featured :)But thanks anyway, I might be able to hack something together.
rassie
Also, another problem with this is that the SVN substitution keywords (e.g. $Date$, $Revision$, $Id$, etc.) will be expanded in the working copy, which you don't want in a diff. "svn diff" doesn't expand these keywords, and that is the behavior you want.