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

bug in svn diff and related?

From: mike south <msouth_at_mcclatchyinteractive.com>
Date: 2005-03-15 08:10:39 CET

Hi,

I posted a couple days ago regarding an issue where I was getting
unexpected output from svn diff.

Now I have a script to reproduce it, and I think that the behavior is
either a bug or a serious omission from the documentation.

It looks to my untrained (and uninformed!) eye as though svn diff may be
checking the mtime of a file against the
.svn/text-base/[filename].svn-base version (the "pristine copy") of the
file, and skipping the diff if the mtimes are the same.

I have code that is adding an empty file to the working copy,
committing, then filling the file with contents, then committing that.

What appears to me to be happening is that some times the commit of the
empty file (and the writing of its .svn/text-base copy) are happening
within the same second that the modify of the file happens. Then when
you try to commit the modified file subversion doesn't see the
modifications, and ignores your commit attempt.

If I go into a working copy and save the included script as 'test.pl',
then run

     perl test.pl 1
     perl test.pl 2
     perl test.pl 3
     perl test.pl 4

I find that sometimes the commit of the changed file is ignored, and
sometimes it isn't. I think that this is because some times I get
lucky and the commit of the change happens in a different second than
the writing of the .svn/text-base copy (speculative, but seems backed up
by experimentation that I'm not demonstrating below).

If I manually set the mtime with perl (three commented-out lines in the
script below), I always see the change being ignored.

If I touch a file that has been ignored and commit, I can commit after
that and it will send the file.

Here is the script:

     #!perl -w
     use strict;
     my $file=shift;
     die "usage:$0 filename" unless $file;
     die "$file exists, try another" if -e $file;
     `touch $file`;
     warn `svn add $file`;
     warn `svn commit -m 'adding empty' $file`;
     `echo "here there be contents" >>$file`;
     # put these lines in to see the problem every time
     #my $base_file="./.svn/text-base/$file.svn-base";
     #my $mtime = (stat $base_file)[9];
     #utime $mtime, $mtime, $file;
     warn ( `svn commit -m 'trying to update' $file` || "commit did not
do anything for $file");

Here is some sample output with me running it as
described above:

     [msouth@rpub200d svn_diff_issue]$ perl test.pl 1
     A 1
     Adding 1
     Transmitting file data .
     Committed revision 33.
     commit did not do anything for 1 at test.pl line 13.
     [msouth@rpub200d svn_diff_issue]$ perl test.pl 2
     A 2
     Adding 2
     Transmitting file data .
     Committed revision 34.
     Sending 2
     Transmitting file data .
     Committed revision 35.
     [msouth@rpub200d svn_diff_issue]$ perl test.pl 3
     A 3
     Adding 3
     Transmitting file data .
     Committed revision 36.
     Sending 3
     Transmitting file data .
     Committed revision 37.
     [msouth@rpub200d svn_diff_issue]$ perl test.pl 4
     A 4
     Adding 4
     Transmitting file data .
     Committed revision 38.
     commit did not do anything for 4 at test.pl line 13.

In the above tests, 1 and 4 exhibited the problem. (For 2 and 3 you can
see that two commits succeeded, where on 1 and 4 you get "commit did not
do anything" warnings from the script.) Here is more activity with file
1 to demonstrate what I was saying about it. It is different from its
pristine copy but svn doesn't seem to see that:

     [msouth@rpub200d svn_diff_issue]$ cat 1
     here there be contents
     [msouth@rpub200d]$ svn cat 1
     [msouth@rpub200d]$ svn diff 1
     [msouth@rpub200d]$ diff .svn/text-base/1.svn-base 1
     0a1
> here there be contents
     [msouth@rpub200d]$ svn commit 1
     [msouth@rpub200d]$ touch 1
     [msouth@rpub200d]$ svn commit -m'this will send the file' 1
     Sending 1
     Transmitting file data .
     Committed revision 40.

please let me know if there is any other information I can provide.

mike

-- 
-----------------------------------------
       Name : Mike South
      Title : Software Developer
    Company : McClatchy Interactive
Work Phone : (919) 861-1259
   Work Fax : (919) 861-1300
Work Email : msouth@mcclatchyinteractive.com
        AIM : msouthmi
   Web Site : http://www.mcclatchyinteractive.com/
-----------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Mar 15 08:15:13 2005

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.