You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Greg Ward <gw...@python.net> on 2005/03/19 03:23:10 UTC

Annoyance merging: "Cannot replace a directory from within"

Trying to merge some changes from the trunk to a recently-created
branch, I'm being stymied by the error message "svn: Cannot replace a
directory from within".  Let me explain the background here so you can
understand what I'm trying to merge and why.

The project in question is Optik, a Python library that has an alternate
life as optparse in the Python standard library.  Optik 1.5a2 was
included with Python 2.4; I've since added some small features, released
Optik 1.5, and am close to releasing Optik 1.5.1.  Alas, those small
features disqualify Optik 1.5 or 1.5.1 from being included with Python
2.4.1.  But I'd like to backport some of the doc changes I've made
leading up to Optik 1.5.1 to Python 2.4.1.  So I "svn copy"'d
/tags/optik-1.5a2 to /branches/python-2.4, just on the offchance that
there might be future bug fixes or other doc changes that absolutely
have to be made in the Python 2.4 branch.  (Plus I've been looking for
an excuse to play around with merging with Subversion.)

Here are the relevant revisions:

  r437  2004-10-26  copy "/trunk" to "/tags/optik-1.5a2"
  r464  2004-11-11  doc fixes/additions in /trunk/doc/reference.txt
  r490  2005-03-08  more doc additions
  r491  2005-03-16  more doc additions
  r495  2005-03-16  more doc additions
  r496  2005-03-16  copy "/tags/optik-1.5a2" to "/branches/python-2.4"
  r497  2005-03-18  more doc additions
  r499  2005-03-18  more doc additions
  r500  2005-03-18  tweak doc-generating script (/trunk/mkpydoc)

What I want to do is merge all of the above doc changes from the trunk
to /branches/python-2.4, since these are the doc changes that I want to
get into Python 2.4.1.  As a rough approximation, I'd be happy to merge
all changes on the trunk from r437 to HEAD to doc/reference.txt on
/branches/python-2.4, and then edit the file to remove text that
describes new features and therefore does not belong in Python 2.4.1.

My first attempt was this (you can play along at home, since this is a
public repository):

  $ svn co svn://starship.python.net/optik/branches/python-2.4 \
           optik-python-2.4
  [...]
  $ cd optik-python-2.4
  $ svn merge -r437:HEAD \
        svn://starship.python.net/optik/trunk/doc/reference.txt
  svn: Cannot replace a directory from within

Huh?  Like others before me, I have google'd for that error message, and
not been terribly enlightened by what I found.  After much screwing
around, I hit upon something that works:

  $ cd doc
  $ svn merge -r437:HEAD \
        svn://starship.python.net/optik/trunk/doc/reference.txt
  U  reference.txt

Note that I'm running the exact same command -- it only works unless I
run it from the directory that contains the file I want to merge.

Can anyone explain 1) what "Cannot replace a directory from within"
means in this context, and 2) why I have to "cd doc" before I can merge
changes into doc/reference.txt?

Thanks --

        Greg
-- 
Greg Ward <gw...@python.net>                         http://www.gerg.ca/
I am NOT a nut....

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Annoyance merging: "Cannot replace a directory from within"

Posted by Ben Collins-Sussman <su...@collab.net>.
On Mar 18, 2005, at 9:23 PM, Greg Ward wrote:
>
>   r437  2004-10-26  copy "/trunk" to "/tags/optik-1.5a2"
>   r464  2004-11-11  doc fixes/additions in /trunk/doc/reference.txt
>   r490  2005-03-08  more doc additions
>   r491  2005-03-16  more doc additions
>   r495  2005-03-16  more doc additions
>   r496  2005-03-16  copy "/tags/optik-1.5a2" to "/branches/python-2.4"
>   r497  2005-03-18  more doc additions
>   r499  2005-03-18  more doc additions
>   r500  2005-03-18  tweak doc-generating script (/trunk/mkpydoc)

All of these changes were made to trunk.

You want to apply them to the branch.


>
> What I want to do is merge all of the above doc changes from the trunk
> to /branches/python-2.4, since these are the doc changes that I want to
> get into Python 2.4.1.  As a rough approximation, I'd be happy to merge
> all changes on the trunk from r437 to HEAD to doc/reference.txt on
> /branches/python-2.4, and then edit the file to remove text that
> describes new features and therefore does not belong in Python 2.4.1.
>
> My first attempt was this (you can play along at home, since this is a
> public repository):
>
>   $ svn co svn://starship.python.net/optik/branches/python-2.4 \
>            optik-python-2.4
>   [...]
>   $ cd optik-python-2.4
>   $ svn merge -r437:HEAD \
>         svn://starship.python.net/optik/trunk/doc/reference.txt
>   svn: Cannot replace a directory from within
>
> Huh?  Like others before me, I have google'd for that error message, 
> and
> not been terribly enlightened by what I found.  After much screwing
> around, I hit upon something that works:
>
>   $ cd doc
>   $ svn merge -r437:HEAD \
>         svn://starship.python.net/optik/trunk/doc/reference.txt
>   U  reference.txt

So you need to compare apples with apples.

Remember that 'svn merge' compares two trees, and applies the 
differences to a working-copy tree.  That means all 3 trees need to 
"line up" semantically.

In your case, you should be comparing two snapshots of trunk, and 
applying them to a working copy of the branch.  (One of your mistakes 
above is asking merge to compare two snapshots of *one file*.  That's 
way too narrow a comparison, unless you're really only interested 
merging changes from/to exactly one file -- but that's not what you 
asked for.)

The syntax for merge is:

      svn merge URL1@X URL2@Y working-copy

or, a shorter form, if the URLs are the same:

      svn merge -rX:Y URL working-copy

So you're making mistakes on multiple levels.  First of all, the reason 
nothing works until you "cd" into a directory is because you're not 
specifying the working copy argument -- which means it's defaulting to 
'.', the current working dir.  (Your first merge attempt was asking svn 
to compare two files, and apply the differences to '.' -- that's 
guaranteed to make no sense.  The difference between two files can only 
be applied to another file!)

What you want to do is

   $ cd branch-working-copy
   $ svn merge -r437:HEAD URL-of-trunk

or, if you don't want to cd into the working copy,

   $ svn merge -r437:HEAD URL-of-trunk branch-working-copy



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org