Examining the Details of Historical Changes

We’ve already seen svn diff before—it displays file differences in unified diff format. We used it to show the local modifications made to our working copy before committing to the repository.

In fact, it turns out that there are three distinct uses of svn diff:

  • Examining local changes

  • Comparing your working copy to the repository

  • Comparing repository revisions

Examining local changes

As we’ve seen, invoking svn diff with no options will compare your working files to the cached pristine copies in the .svn area:

$ svn diff
Index: rules.txt
===================================================================
--- rules.txt	(revision 3)
+++ rules.txt	(working copy)
@@ -1,4 +1,5 @@
 Be kind to others
 Freedom = Responsibility
 Everything in moderation
-Chew with your mouth open
+Chew with your mouth closed
+Listen when others are speaking
$

Comparing working copy to repository

If a single --revision (-r) number is passed, your working copy is compared to the specified revision in the repository:

$ svn diff -r 3 rules.txt
Index: rules.txt
===================================================================
--- rules.txt	(revision 3)
+++ rules.txt	(working copy)
@@ -1,4 +1,5 @@
 Be kind to others
 Freedom = Responsibility
 Everything in moderation
-Chew with your mouth open
+Chew with your mouth closed
+Listen when others are speaking
$

Comparing repository revisions

If two revision numbers, separated by a colon, are passed via --revision (-r), the two revisions are directly compared:

$ svn diff -r 2:3 rules.txt
Index: rules.txt
===================================================================
--- rules.txt	(revision 2)
+++ rules.txt	(revision 3)
@@ -1,4 +1,4 @@
 Be kind to others
-Freedom = Chocolate Ice Cream
+Freedom = Responsibility
 Everything in moderation
 Chew with your mouth open
$

A more convenient way of comparing one revision to the previous revision is to use the --change (-c) option:

$ svn diff -c 3 rules.txt
Index: rules.txt
===================================================================
--- rules.txt	(revision 2)
+++ rules.txt	(revision 3)
@@ -1,4 +1,4 @@
 Be kind to others
-Freedom = Chocolate Ice Cream
+Freedom = Responsibility
 Everything in moderation
 Chew with your mouth open
$

Lastly, you can compare repository revisions even when you don’t have a working copy on your local machine, just by including the appropriate URL on the command line:

$ svn diff -c 5 http://svn.example.com/repos/example/trunk/text/rules.txt
...
$
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset