Csaba Faragó
Csaba Faragó

Reputation: 473

Inconsistent result of SVN diff command

Problem: the svn diff command seems to be inconsistent when executing on a whole repository, compared with the execution on a single file.

An example: consider the r542208 commit of the Apache Tomcat source code.

svn log -v -r r542208 http://svn.apache.org/repos/asf/

Result:

------------------------------------------------------------------------
r542208 | fhanik | 2007-05-28 13:39:15 +0200 (H, 28 máj. 2007) | 2 lines
Changed paths:
   M /tomcat/trunk/java/org/apache/catalina/connector/CometEventImpl.java
   M /tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
   M /tomcat/trunk/java/org/apache/catalina/connector/Request.java
   M /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
   M /tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java

Implement setTimeout using an Action instead of an attribute

------------------------------------------------------------------------

Now let's consider source file /tomcat/trunk/java/org/apache/catalina/connector/Request.java. Executing a repository wide diff provides some result.

svn diff -r r542207:r542208 http://svn.apache.org/repos/asf/tomcat

The Request.java related part of the result is the following:

===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java       (revision 542207)
+++ trunk/java/org/apache/catalina/connector/Request.java       (revision 542208)
@@ -2259,6 +2259,9 @@

     // ------------------------------------------------------ Protected Methods

+    protected void action(ActionCode actionCode, Object param) {
+        coyoteRequest.action(actionCode,param);
+    }

     protected Session doGetSession(boolean create) {

(There are other parts of the result as well.)

But if we execute the diff command on that file only, the result will be empty.

svn diff -r r542207:r542208 http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/connector/Request.java

I would expect the same result as quoted above.

It is also strange that the above indicated 3 new lines are missing when listing that version of the source file, but the line above and below exist.

The question: what could cause this strange behavior? Is there any setting which maps the basis of the SVN to other directory (a branch for example)? Or maybe a later directory rename could cause this problem?

Upvotes: 4

Views: 219

Answers (1)

Alas, you fell victim to the "Peg Revision Fallacy". Some time in its history, the file Request.java was replaced by another file of the same name. Therefore, you need to make sure that you also specific the correct peg revision when querying the repository, which is done by appending @revision to the path in question. Thus, the following command will yield nothing (as you reported)

svn diff -r r542207:r542208 http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/connector/Request.java

but if you add the correct peg revision, you will see the expected changes:

svn diff -r r542207:r542208 http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/connector/Request.java@542207

The revision in which the the original Request.java was removed is 573772, in which the whole repository tree was deleted and replaced by another one. More information can be found at http://svnbook.red-bean.com/en/1.8/svn.advanced.pegrevs.html.

Upvotes: 5

Related Questions