Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

svn diff for a complete file?

Tags:

diff

svn

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: ?

like image 318
Nikolai Prokoschenko Avatar asked Aug 21 '09 12:08

Nikolai Prokoschenko


People also ask

How do I diff files in svn?

Just hold down the Shift key while you right click on the file. Then select TortoiseSVN → Diff with URL. In the following dialog, specify the URL in the repository with which you want to compare your local file to.

How do you find the difference between two revisions in svn?

Use just svn diff'to display local modifications in a working copy. Display the changes made to TARGET s as they are seen in REV between two revisions. TARGET s may be all working copy paths or all URL s.

How do I compare changes in svn?

If you want to compare two revisions in an item's history, for example revisions 100 and 200 of the same file, just use TortoiseSVN → Show Log to list the revision history for that file. Pick the two revisions you want to compare then use Context Menu → Compare Revisions.

How do I commit a specific file in svn?

If your working copy is up to date and there are no conflicts, you are ready to commit your changes. Select any file and/or folders you want to commit, then TortoiseSVN → Commit.... The commit dialog will show you every changed file, including added, deleted and unversioned files.


2 Answers

Without temp file:

echo "" | diff -u - script.pl
like image 134
RJR Avatar answered Sep 19 '22 15:09

RJR


Some versions of SVN seems to let you do svn diff -r 0:HEAD file.txt, but some don't. For those that don't, use the following:

svn diff --old=/path/to/root/of/repo@1 --new=/path/to/file.txt

Both of these work for any folder/file/files!

like image 34
Rich Avatar answered Sep 16 '22 15:09

Rich