Re: Differences between WC->WC copy, URL->URL copy, and $dirent->created_rev()

Nik Clayton <[email protected]> Sun, 29 Jan 2006 11:06:19 +0000
Newsgroups gmane.comp.version-control.subversion.devel,gmane.mail.eyebrowse.user
Message-ID <[email protected]>
--------------080305010504040604040509
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

[ Copied dev list, at the suggestion of members of #svn-dev ]

Alan, thanks for your suggestion.

Alan Barrett wrote:
> On Thu, 26 Jan 2006, Nik Clayton wrote:
>> Suppose your repo looks like this:
>>
>>   Entry			Created in
>>   /trunk			   1
>>   /branches                     1
>>
>>   /trunk/foo                    2
>>   /trunk/bar                    2
>>
>>   /branches/test1               3   Copied from trunk:2, WC -> WC
> 
> When you did this, I suspect that you had a "mixed" working copy, in
> which /trunk was at revision 1 but /trunk/foo and /trunk/bar were at
> revision 2.  If you "svn update" in the working copy of /trunk just
> before doing the WC -> WC copy, so that the whole thing is consistently
> at revision 2, I think you'll get different results.

I've just tried that.  I took 'mkrepo.sh' from my first message, and added:

     svn update
     svn info .

immediately after the

     svn commit -m 'Add foo and bar'

line.  The following commands carry out the WC -> WC copy.

Re-running the script, the 'svn update' output is:

     At revision 2

and the 'svn info' output is:

     Path: .
     URL: file:///tmp/repo/trunk
     Repository Root: file:///tmp/repo
     Repository UUID: 2bdbe6c2-b290-da11-8650-0011251291e9
     Revision: 2
     Node Kind: directory
     Schedule: normal
     Last Changed Author: nik
     Last Changed Rev: 2
     Last Changed Date: 2006-01-29 10:34:02 +0000 (Sun, 29 Jan 2006)

which would seem to confirm that trunk/ is definitely at r2 prior to the WC 
-> WC copy.

The rest of the script runs as normal.  However, this causes an additional 
test regression.

1..7
ok 1 - ra/repos agree on youngest rev
ok 2 - ra/repos agree on interesting rev for /trunk/foo
ok 3 - ra/repos agree on interesting rev for /trunk/bar
not ok 4 - ra/repos agree on interesting rev for /branches/test1/foo
#   Failed test 'ra/repos agree on interesting rev for /branches/test1/foo'
#   in test.pl at line 30.
#          got: '2'
#     expected: '3'
ok 5 - ra/repos agree on interesting rev for /branches/test1/bar
not ok 6 - ra/repos agree on interesting rev for /branches/test2/foo
#   Failed test 'ra/repos agree on interesting rev for /branches/test2/foo'
#   in test.pl at line 30.
#          got: '2'
#     expected: '5'
ok 7 - ra/repos agree on interesting rev for /branches/test2/bar
# Looks like you failed 2 tests of 7.

As well as test 6 failing, test 4 now fails.  The error indicates that the 
Ra layer thinks that the latest interesting rev is 2, while the Repos layer 
thinks that it's 3.

If I back out your suggested change and re-run the tests then both layers 
agree that the interesting rev is 3.

So carrying out the 'svn update' seems to confuse the Ra layer even more.

>> This difference is also reflected in the 'svn log' output.
>>
>> With the WC -> WC copy you see this from 'svn log'
>>
>>   ...
>>   Changed paths:
>>     A /branches/test1 (from /trunk:1)
>>     A /branches/test1/bar (from /trunk/bar:2)
>>     A /branches/test1/foo (from /trunk/foo:2)
>>   ...
> 
> See that it copied /trunk from revision 1, not from revision 2, so it
> had to explicitly override foo and bar by copying them from revision 2.

With your suggested change the log output from r3 is different.  It's now just:

   ...
   Changed paths:
      A /branches/test1 (from /trunk:2)
   ...

'foo' and 'bar' aren't mentioned.  Which is, I suppose, good.  However, as I 
say, your change causes an additional inconsistency between Ra and Repos.

> Right.  If you think that this sort of copy is "interesting" for the
> purposes of your script, you'll have to detect it somehow.  I don't know
> the right APIs for that.

I think this is a bug, or at least a strange inconsistency.  I've also got a 
slightly simpler test case that doesn't involve Perl.

Take the attached mkrepos.sh and run it -- it's the same as the one attached 
to my last message, save that I've added your suggested 'svn update' step.

     sh mkrepos.sh /tmp/repo

Get info about /branches/test1/foo

     svn info file:///tmp/repo/branches/test1/foo
     Path: foo
     Name: foo
     URL: file:///tmp/repo/branches/test1/foo
     Repository Root: file:///tmp/repo
     Repository UUID: 55c3d20a-b690-da11-8650-0011251291e9
     Revision: 6
     Node Kind: file
     Last Changed Author: nik
     Last Changed Rev: 2
     Last Changed Date: 2006-01-29 10:57:32 +0000 (Sun, 29 Jan 2006)

Note that "Last Changed Rev" is 2.

Now get the log for /branches/test1/foo

     svn log file:///tmp/repo
     ------------------------------------------------------------------------
     r3 | nik | 2006-01-29 10:57:35 +0000 (Sun, 29 Jan 2006) | 1 line
     Changed paths:
        A /branches/test1 (from /trunk:2)

     Create test1 with "svn copy trunk branches/test1"
     ------------------------------------------------------------------------
     r2 | nik | 2006-01-29 10:57:32 +0000 (Sun, 29 Jan 2006) | 1 line
     Changed paths:
        A /trunk/bar
        A /trunk/foo

     Add foo and bar
     ------------------------------------------------------------------------

According to the log, there was a change to this file in r3.  'svn info' 
says it was changed in r2.

There's the same discrepancy with /branches/test2/foo (expect that 'svn log' 
shows a commit in r5, but 'svn info' thinks the last change was in 'r2').

Hmm.

N

--------------080305010504040604040509
Content-Type: text/plain;
 name="mkrepo.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mkrepo.sh"

#!/bin/sh

repo=file://$1

if [ "$1x" = "x" ]; then
	echo "usage: $0 /path/to/repo"
	exit
fi

# Blow away repo directory, and WC
rm -rf $1/*
rm -rf repo

# Create new repo, check it out, cd(1) to it.
svnadmin create /tmp/repo
svn checkout $repo
cd repo

# Create trunk/ and branches/
mkdir trunk branches
svn add trunk branches
svn commit -m 'trunk branches' trunk branches

# Create two files in trunk/
cd trunk
touch foo bar
svn add foo bar
svn commit -m 'Add foo and bar'

# Suggested by Alan Barrett -- make sure that I don't have a mixed
# working copy.
svn update
svn info .

# Copy trunk/ to branches/test1/, using a WC -> WC copy, and ::Ra and
# ::Repos both handle this properly
cd ..
svn copy trunk branches/test1
svn commit -m 'Create test1 with "svn copy trunk branches/test1"'
svn update

# Make a change to branches/test1/bar and commit.
cd branches/test1
echo bar > bar
svn commit -m "Add 'bar'"

# Copy trunk/ to branches/test2/, using a URL -> URL copy.  ::Ra wil have
# problems with this.
svn copy $repo/trunk $repo/branches/test2 -m 'Create test2 with immediate copy'
cd ..
svn update

# Make a change to branches/test2/bar, and commit.  ::Ra and ::Repos will now
# agree on the youngest rev for branches/test2/bar, but they will disagree
# on the youngest rev for branches/test2/foo (which has not been changed
# since it was copied).  This is the issue.
cd test2
echo bar > bar
svn commit -m "Add 'bar'"

echo Now run:
echo
echo "    perl test.pl $1"


--------------080305010504040604040509
Content-Type: text/plain; charset=us-ascii

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--------------080305010504040604040509--