On 02/26/2018 12:18 AM, Stefan Sperling wrote:
On Sun, Feb 25, 2018 at 11:38:03PM -0800, Alexey Neyman wrote:
Hi all,

I am trying to dig for some changes in a file that was moved a few times and
'svn diff' shows full "remove old location and add new location as if it
were a new file" diffs, which are not helpful. Is there a way to make the
diff show the changes as compared against the origin of the copy? I tried
--notice-ancestry, does not help.
Diff output changes depending on whether you pass a path to the
file itself or to a parent of the file. Try: svn diff -c 2 barfoo
I found this in the diff_renamed_file() test in diff_tests.py,
see there for more examples.
https://svn.apache.org/repos/asf/subversion/trunk/subversion/tests/cmdline/diff_tests.py
You don't expect the end-user to read the test cases in the product to get these subtleties, do you? :)

And, I find it quite counter-intuitive. I would expect --notice-ancestry at least to take ancestral relationship between these files into account; the currently shown diff is the same as if 'barfoo' were not copied but was created from scratch.

Since you know all paths and revisions involved, you could also run:
   svn diff ^/foobar@1 ^/barfoo@2
Well, either of these approaches is not very convenient when there is a dozen moves & modifications in a single revision.

Besides, the former (just passing the path) does not seem to work in all cases. In the real repository, I have two revisions that did the same thing: moved a directory and modified some files in the moved directory. The trick with passing the path to the file works for one of them, but not for the other - and I am at a loss why SVN treats these two differently. Here's where diff does not display the proper diff even when supplied with the path to the file:

# The relevant fragment of a revision
$ svn log -c 36 -v file://`pwd`/XXXXXX-svn
   A /trunk/XXXXXX/src/bin/more (from /vendor/YYYY:29)
   M /trunk/XXXXXX/src/bin/more/more.c
# Passing the path to the directory that was copied: does not work
$ svn di -c 36 file://`pwd`/XXXXXX-svn/trunk/XXXXXX/src/bin/more | grep -A 4 'Index: more.c'
Index: more.c
===================================================================
--- more.c      (nonexistent)
+++ more.c      (revision 36)
@@ -0,0 +1,1894 @@
# Passing the path to the specific file: does not work
$ svn di -c 36 file://`pwd`/XXXXXX-svn/trunk/XXXXXX/src/bin/more/more.c | grep -A 4 'Index: more.c'
Index: more.c
===================================================================
--- more.c      (nonexistent)
+++ more.c      (revision 36)
@@ -0,0 +1,1894 @@
# Manual, file-by-file: works, but doesn't scale to revisions with lots of modifications $ svn di file://`pwd`/los178-svn{/vendor/YYYY/more.c@29,/trunk/XXXXX/src/bin/more/more.c@36} | grep -A 4 'Index: more.c'
Index: more.c
===================================================================
--- more.c      (.../vendor/BSD/more/4.3Tahoe/more.c)   (revision 29)
+++ more.c      (.../trunk/los178/src/bin/more/more.c)  (revision 36)
@@ -1,3 +1,11 @@


Regards,
Alexey.


I have a vague recollection that 'svn diff' used to show the changes in such
copied files before - but I tried the small reproduction script below and it
shows the same, both with 1.7.22/1.8.17/1.9.7/trunk:

---8<---
#!/bin/bash

rm -rf /tmp/foo-{svn,wc}
svnadmin create /tmp/foo-svn
svn co file:///tmp/foo-svn foo-wc
cd foo-wc
echo foo > foobar
svn add foobar
svn ci -m "1"
svn mv foobar barfoo
echo bar >> barfoo
svn ci -m "2"
svn up
svn diff -c 2
svn --version
---8<---


Diff output:

---8<---
Index: foobar
===================================================================
--- foobar    (revision 1)
+++ foobar    (nonexistent)
@@ -1 +0,0 @@
-foo
Index: barfoo
===================================================================
--- barfoo    (nonexistent)
+++ barfoo    (revision 2)
@@ -0,0 +1,2 @@
+foo
+bar
---8<----

Regards,
Alexey.


Reply via email to