You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Alexis Huxley <ah...@gmx.net> on 2002/12/09 21:24:22 UTC

can't 'svn cp' *twice* - bug or prohibited?

Hi, 

I've got a file in a working copy. Actually, I want a second copy of
it. So I 'svn cp' it. Fine.

A few weeks later I realise that the copy has not been updated to
stay in line with the 'original', which has had many changes applied
and commited in the intervening period.

Rather than 'cp' it, and lose the knowledge of where the cp-induced
changes come from, I'd like to 'svn cp' it again.

Unfortunately it doesn't work. It says:

	svn: Entry already exists
	svn: file `wc/file2' already exists.

Is there some reason I'm not seeing why this has to be prohibited,
or is it a bug? I checked the issues but didn't manage to find a match.

This is 4042.

Here's the recipe:

	svnadmin create repos
	svn co file://`pwd`/repos wc

	touch wc/file1
	svn add wc/file1
	svn commit -m "added file1" wc

	svn cp wc/file1 wc/file2
	svn commit -m "copied file1 to file2" wc
	
	echo "here is a change to file1" > wc/file1
	svn commit -m "changed file1" wc

	svn cp wc/file1 wc/file2

Alexis

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

Re: can't 'svn cp' *twice* - bug or prohibited?

Posted by Philip Martin <ph...@codematters.co.uk>.
Alexis Huxley <ah...@gmx.net> writes:

> I've got a file in a working copy. Actually, I want a second copy of
> it. So I 'svn cp' it. Fine.
> 
> A few weeks later I realise that the copy has not been updated to
> stay in line with the 'original', which has had many changes applied
> and commited in the intervening period.
> 
> Rather than 'cp' it, and lose the knowledge of where the cp-induced
> changes come from, I'd like to 'svn cp' it again.

There are two choices: 1) 'svn rm' the second file and then 'svn cp'
the first file again, or 2) 'svn merge' the first file into the second
file.

> Unfortunately it doesn't work. It says:
> 
> 	svn: Entry already exists
> 	svn: file `wc/file2' already exists.
> 
> Is there some reason I'm not seeing why this has to be prohibited,
> or is it a bug? I checked the issues but didn't manage to find a match.

That's the intended beahviour.

> Here's the recipe:
> 
> 	svnadmin create repos
> 	svn co file://`pwd`/repos wc
> 
> 	touch wc/file1
> 	svn add wc/file1
> 	svn commit -m "added file1" wc
> 
> 	svn cp wc/file1 wc/file2
> 	svn commit -m "copied file1 to file2" wc
>
> 	echo "here is a change to file1" > wc/file1
> 	svn commit -m "changed file1" wc
> 
> 	svn cp wc/file1 wc/file2

I'll assume you can handle the 'svn rm' followed by 'svn cp' option,
so I'll just describe 'svn merge' :)

If file2 was created by copying revision X of file1 then you want to
merge all the changes made to file1 between X and HEAD.  So use

  svn merge -rX:HEAD url_of_file1 wc/file2

If you make further changes to file1 you can use merge to add those to
file2 as well.  A second merge would use '-rY:HEAD' where Y is the
revision that was HEAD in the previous merge.

-- 
Philip Martin

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

Re: can't 'svn cp' *twice* - bug or prohibited?

Posted by Peter Davis <pe...@pdavis.cx>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 09 December 2002 14:25, Alexis Huxley wrote:
> Doh! Thanks! :-) Still wondering *why* though ...

I guess because Subversion's philosophy is to never destroy data.  Even though 
file2 is unmodified locally, Subversion still wants you to explicitely "svn 
remove" it before it will allow you to overwrite it.

This avoids any suprises if, for example, file2 had been committed by someone 
else and you simply didn't notice that it existed.  Even though the old 
version would still be recoverable from the repository, it's better to 
require explicit deletion.

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE99S0thDAgUT1yirARAi+6AJ9jzYNRGBmA5o4sJL4GW2fLi5IPpgCfe3hU
OcypeGhtgI8SENpAOl7XHtA=
=JMSQ
-----END PGP SIGNATURE-----


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

Re: can't 'svn cp' *twice* - bug or prohibited?

Posted by Alexis Huxley <ah...@gmx.net>.
> The manpage says about copy:

Doh! Thanks! :-) Still wondering *why* though ...

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

Re: can't 'svn cp' *twice* - bug or prohibited?

Posted by "Andreas J. Koenig" <an...@anima.de>.
>>>>> On Mon, 9 Dec 2002 22:24:22 +0100, Alexis Huxley <ah...@gmx.net> said:

  > Rather than 'cp' it, and lose the knowledge of where the cp-induced
  > changes come from, I'd like to 'svn cp' it again.

  > Unfortunately it doesn't work. It says:

  > 	svn: Entry already exists
  > 	svn: file `wc/file2' already exists.

The manpage says about copy:

    Unless destination is a directory, destination must not exist (In
    the spirit of unix cp, source will be placed inside of destination
    if destination is a directory).


-- 
andreas

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