You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Anthony Foglia <AF...@princeton.com> on 2010/09/10 16:06:42 UTC

Branching directories with fully-contained externals with svncopy.pl

I have found a bug in the svncopy.pl script that fails to properly 
handle fully-contained externals when branching and copying from a 
single source.  When branching from a single source, the externals are 
updated to directories that do not exist.

Taken from the README 
<http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svncopy/svncopy.README>, 
example 5 "branching properly"...

---
Using the script allows branches to be created which are really independent.

$ perl svncopy.pl --branch http://svn/repos/trunk \
             http://svn/repos/branches/3.2_bugfix

Result:

trunk/
     [ as above]
branches/
     3.2_bugfix/
         trunk/
             common/
                 common1.c
                 common2.c
             inc/
                 common1.h
                 common2.h
             proj_foo/
                 foo1.c
                 foo2.c
                 X common    -r 4997 http://svn/repos/trunk/common
                 X inc       http://svn/repos/branches/3.2_bugfix/trunk/inc
[rest of example tree omitted]
---

The current svncopy.pl script has special logic for a single source and 
no longer creates the branches/3.2_bugfix/trunk directory, but puts the 
contents directly in branches/3.2_bugfix.  The logic is more along the 
lines of the "svn copy" command.  (This was added in a patch a year ago. 
  <http://svn.haxx.se/dev/archive-2009-06/0064.shtml>)

The problem is the fully-contained external, when updated for the 
branch, is still updated to what the non-patched version would have 
created, http://svn/repos/branches/3.2_bugfix/trunk/inc, which no longer 
exists.

I can try to fix it, but I have very little Perl experience, and 
definitely not enough to easily understand the testsvncopy.pl script to 
make a test case.

Here is the verbose output of a branch command up until the error first 
appears.

$ svncopy.pl -b --verbose 
https://192.168.1.197/svn/ASA/branches/release/trunk-v01_00b2/trunk 
https://192.168.1.197/svn/ASA/Sandbox/AF/tmp/branch_test

=================================================================
=== Copying from:
=== 
https://192.168.1.197/svn/ASA/branches/release/trunk-v01_00b2/trunk
===
=== Copying to:
===       https://192.168.1.197/svn/ASA/Sandbox/AF/tmp/branch_test
===
===  - branching (updating fully-contained svn:externals definitions)
===
multiple_sources: No
Using temporary directory /tmp/svncopy_S1AkIqIak9
Copying source URI to destination URI
  > svn copy --file /tmp/svncopy_S1AkIqIak9/CDYv8LFfbX 
https://192.168.1.197/svn/ASA/branches/release/trunk-v01_00b2/trunk 
https://192.168.1.197/svn/ASA/Sandbox/AF/tmp/branch_test
Checking out destination directory '/tmp/svncopy_S1AkIqIak9/branch_test'
  > svn co https://192.168.1.197/svn/ASA/Sandbox/AF/tmp/branch_test 
/tmp/svncopy_S1AkIqIak9/branch_test
Checking '/tmp/svncopy_S1AkIqIak9/branch_test'
  > svn propget -R svn:externals /tmp/svncopy_S1AkIqIak9/branch_test
  - Found c-SimpleReturns => 
'https://192.168.1.197/svn/ASA/branches/release/trunk-v01_00b2/trunk/projects/barring/toolkit-simple-returns/c-SimpleReturns'
  - updated 'c-SimpleReturns 
https://192.168.1.197/svn/ASA/branches/release/trunk-v01_00b2/trunk/projects/barring/toolkit-simple-returns/c-SimpleReturns' 
to 'c-SimpleReturns 
https://192.168.1.197/svn/ASA/Sandbox/AF/tmp/branch_test/trunk/projects/barring/toolkit-simple-returns/c-SimpleReturns'
[rest omitted]

Again, note that although the branch is at branch_test, the new external 
points to branch_test/trunk.

-- 
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

Re: Branching directories with fully-contained externals with svncopy.pl

Posted by Anthony Foglia <AF...@princeton.com>.
Anthony Foglia wrote:
> I have found a bug in the svncopy.pl script that fails to properly 
> handle fully-contained externals when branching and copying from a 
> single source.  When branching from a single source, the externals are 
> updated to directories that do not exist.

I've figured out where the problem is and have attached a patch 
(single_source_and_branching.patch) that correctly rewrites the 
externals when branching using Bradey Honsinger's patch.

There is still another bug with his patch that is probably too 
complicated for my perl skills.  When you use svncopy.pl to copy from a 
single source to a destination folder that already exists, like "svn 
copy" it makes a subdirectory named with the last component of the 
source directory.  But when it tries to fix the externals, it checks out 
the destination directory (as passed on the command-line), and any of 
its siblings, and tries to change the externals in those directories.

So, if you have a repository of the form

repos/
   branches/
     release_2.0/
   tags/
     release_1.0/

And you do

$ svncopy.pl --tag repos/branches/release_2.0 repos/tags

The script will make repos/tags/release_2.0, but checkout repos/tags and 
try to change all the externals in there, including those in release_1.0.

The workaround is to make sure the source is always a non-existent 
directory, and let the script create it.  So the above command should be.

$ svncopy.pl --tag repos/branches/release_2.0 repos/tags/release_2.0

-- 
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233

Re: Branching directories with fully-contained externals with svncopy.pl

Posted by Anthony Foglia <AF...@princeton.com>.
While fixing the other bug, I discovered another quirk.  When tagging a 
directory with fully-contained externals, those externals are not 
repointed, but merely pinned to the current revision.  It would be more 
aesthetically clean if it repointed them inside the tagged copy as well.

So I made the changes in the attached patch to allow simultaneous 
branching and tagging.  When svncopy.pl is called with both --branch and 
--tag as arguments, it will repoint any fully-contained externals to be 
within the copy, and pin the revisions of any other externals.  (The 
former are not pinned.)

-- 
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233