[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: 1.6 vs. 1.8: strange behavior of 'svn diff -cN WC-FILE' if the file was created in rev N by copying

From: Johan Corveleyn <jcorvel_at_gmail.com>
Date: Tue, 25 Jun 2013 21:56:38 +0200

On Tue, Jun 25, 2013 at 9:47 PM, Johan Corveleyn <jcorvel_at_gmail.com> wrote:
> On Tue, Jun 25, 2013 at 4:24 PM, Tobias Bading <tbading_at_web.de> wrote:
>> Dear Devs,
>>
>> GNU Emacs 24.3 was behaving a little odd today while trying to display a svn
>> diff from Annotate mode. It simply barked "svn: Unable to find repository
>> location for '...' in revision ..." at me :-(. Since this wasn't the first
>> time Emacs left me in the rain like this, I thought it was time to take a
>> closer look.
>>
>> This much I was able to figure out:
>>
>> If you copy a file from revision N-1, modify the copy and then commit it as
>> revision N, 'svn diff -cN FILE' works as expected afterwards. It works no
>> matter whether you use Subversion 1.6 or 1.8, no matter whether you specify
>> FILE as a working copy path or a repository URL. "Works as expected" meaning
>> that it shows the modifications you made, not the entire file as an add.
>>
>> However, if you copy a file from a revision M that is smaller than N-1,
>> modify the copy and then commit it as revision N, 'svn diff -cN FILE' won't
>> play along. Subversion 1.6 simply barks "svn: Unable to find repository
>> location for 'FILE' in revision N-1", whereas Subversion 1.8 shows the whole
>> file as an add, i.e. does a diff -r0:N :-(.
>
> No, it doesn't:
>
> [[[
> C:\Temp\svntest>svn --version -q
> 1.8.0
>
> C:\Temp\svntest>svnadmin create repos
>
> C:\Temp\svntest>svn co file:///c:/temp/svntest/repos wc
> Checked out revision 0.
>
> C:\Temp\svntest>cd wc
>
> C:\Temp\svntest\wc>echo "line 1" > file.txt
>
> C:\Temp\svntest\wc>svn add file.txt
> A file.txt
>
> C:\Temp\svntest\wc>svn ci -mm
> Adding file.txt
> Transmitting file data .
> Committed revision 1.
>
> C:\Temp\svntest\wc>svn mkdir -mm file:///c:/temp/svntest/repos/dir
>
> Committed revision 2.
>
> C:\Temp\svntest\wc>svn up
> Updating '.':
> A dir
> Updated to revision 2.
>
> C:\Temp\svntest\wc>svn mv file.txt moved.txt
> A moved.txt
> D file.txt
>
> C:\Temp\svntest\wc>echo "line 2" >> moved.txt
>
> C:\Temp\svntest\wc>svn st
> D file.txt
> > moved to moved.txt
> A + moved.txt
> > moved from file.txt
>
> C:\Temp\svntest\wc>svn ci -mm
> Deleting file.txt
> Adding moved.txt
> Transmitting file data .
> Committed revision 3.
>
> C:\Temp\svntest\wc>svn up
> Updating '.':
> At revision 3.
>
> C:\Temp\svntest\wc>svn diff -c3
> Index: file.txt
> ===================================================================
> --- file.txt (revision 2)
> +++ file.txt (revision 3)
> @@ -1 +0,0 @@
> -"line 1"
> Index: moved.txt
> ===================================================================
> --- moved.txt (revision 0)
> +++ moved.txt (revision 3)
> @@ -0,0 +1,2 @@
> +"line 1"
> +"line 2"
>
> C:\Temp\svntest\wc>svn diff -c3 moved.txt
> Index: file.txt
> ===================================================================
> --- file.txt (.../file.txt) (revision 2)
> +++ file.txt (.../moved.txt) (revision 3)
> @@ -1 +1,2 @@
> "line 1"
> +"line 2"
> ]]]
>
> That last diff seems to be the one you want, right?
>
> Or could this be a mixed revision thingy? In your script there was no
> 'svn update' after committing revision 2, so the copy was made from f1
> with working revision 1. In my example it's copied from working
> revision 2 (even though it was last changed in r1).
>

Okay, gotcha:

[[[
C:\Temp\svntest>svnadmin create repos

C:\Temp\svntest>svn co file:///c:/temp/svntest/repos wc
Checked out revision 0.

C:\Temp\svntest>cd wc

C:\Temp\svntest\wc>echo "line 1" > file.txt

C:\Temp\svntest\wc>svn add file.txt
A file.txt

C:\Temp\svntest\wc>svn ci -mm
Adding file.txt
Transmitting file data .
Committed revision 1.

C:\Temp\svntest\wc>svn mkdir -mm file:///c:/temp/svntest/repos/dir

Committed revision 2.

C:\Temp\svntest\wc>svn mv file.txt moved.txt
A moved.txt
D file.txt

C:\Temp\svntest\wc>echo "line 2" >> moved.txt

C:\Temp\svntest\wc>svn st
D file.txt
> moved to moved.txt
A + moved.txt
> moved from file.txt

C:\Temp\svntest\wc>svn ci -mm
Deleting file.txt
Adding moved.txt
Transmitting file data .
Committed revision 3.

C:\Temp\svntest\wc>svn diff -c3
Index: file.txt
===================================================================
--- file.txt (revision 2)
+++ file.txt (revision 3)
@@ -1 +0,0 @@
-"line 1"
Index: moved.txt
===================================================================
--- moved.txt (revision 0)
+++ moved.txt (revision 3)
@@ -0,0 +1,2 @@
+"line 1"
+"line 2"

C:\Temp\svntest\wc>svn diff -c3 moved.txt
Index: moved.txt
===================================================================
--- moved.txt (revision 0)
+++ moved.txt (revision 3)
@@ -0,0 +1,2 @@
+"line 1"
+"line 2"

C:\Temp\svntest\wc>svn up
Updating '.':
A dir
Updated to revision 3.

C:\Temp\svntest\wc>svn diff -c3 moved.txt
Index: moved.txt
===================================================================
--- moved.txt (revision 0)
+++ moved.txt (revision 3)
@@ -0,0 +1,2 @@
+"line 1"
+"line 2"

C:\Temp\svntest\wc>svn diff -c3
Index: file.txt
===================================================================
--- file.txt (revision 2)
+++ file.txt (revision 3)
@@ -1 +0,0 @@
-"line 1"
Index: moved.txt
===================================================================
--- moved.txt (revision 0)
+++ moved.txt (revision 3)
@@ -0,0 +1,2 @@
+"line 1"
+"line 2"
]]]

That's indeed ... strange, to say the least. Why should it matter, in
this case, what working revision the copy was made from? I'd say this
is a bug.

Interestingly, 'svnlook diff --diff-copy-from' shows the correct thing
in both cases:
[[[
C:\Temp\svntest\repos>svnlook diff --diff-copy-from -r3 .
Deleted: file.txt
===================================================================
--- file.txt 2013-06-25 19:48:59 UTC (rev 2)
+++ file.txt 2013-06-25 19:49:07 UTC (rev 3)
@@ -1 +0,0 @@
-"line 1"

Copied: moved.txt (from rev 1, file.txt)
===================================================================
--- file.txt 2013-06-25 19:48:55 UTC (rev 1)
+++ moved.txt 2013-06-25 19:49:07 UTC (rev 3)
@@ -1 +1,2 @@
 "line 1"
+"line 2"

C:\Temp\svntest\repos>svnlook diff --diff-copy-from --no-diff-deleted -r3 .
Copied: moved.txt (from rev 1, file.txt)
===================================================================
--- file.txt 2013-06-25 19:48:55 UTC (rev 1)
+++ moved.txt 2013-06-25 19:49:07 UTC (rev 3)
@@ -1 +1,2 @@
 "line 1"
+"line 2"
]]]

So it seems 'svnlook diff' has the better logic here (or at least a
good option).

--
Johan
Received on 2013-06-25 21:57:33 CEST

This is an archived mail posted to the Subversion Dev mailing list.