Quantcast
Viewing all articles
Browse latest Browse all 3

Subversion Tip of the Week

The ‘SVN Diff’ Command

‘SVN Diff’ is a command for highlighting the differences between two paths. This is useful in a number of common scenarios:

1) Comparing versions of the same file, in different locations

Your project may contain different versions of the same file, for example one version in the trunk and one in a branch. To flag up the differences between the two versions, use the following command:

svn diff (repository-URL/trunk/filename) (repository-URL/branches/filename)

In this example, we are comparing a file called ‘Admin Guide’ that appears in both the trunk and in a branch called ‘Admin Text.’

Image may be NSFW.
Clik here to view.

This will list information such as the revision the file is at in both the trunk and the branch, alongside a print-out of the differences.

Tip. If you see the following error message when entering the ‘svn diff’ command:

OPTIONS of (repository URL) 200 OK (repository URL)

It usually means you entered the repository URL incorrectly – go back and check for typos!

2) Comparing your project/files at different revisions

As Apache Subversion remembers every change committed to the repository, it is possible to compare specific files, or even your whole project, at different revisions.

To compare two revisions of your project, the following command can be used:

svn diff (repository-URL) -r(Revision):(Revision)

In this example, we are comparing revision 5 of our repository with the head revision.

Image may be NSFW.
Clik here to view.

If you want to compare the differences between two revisions of a specific file, you simply add the location of the file and the filename to your command:

svn diff (repository-URL/file-path/filename) -r(Revision):(Revision)

In this example, we’re comparing revisions 8 and 10 of a text file named ‘Notes,’ which is located in the trunk:

Image may be NSFW.
Clik here to view.

Tip. The ‘SVN Diff’ command ignores the ancestry of files by default, to alter this add the ‘–notice-ancestry’ switch.


Viewing all articles
Browse latest Browse all 3

Trending Articles