You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by BRM <bm...@yahoo.com> on 2008/12/22 19:44:09 UTC

SVN Copy Question...

I have two repository trees I am working on merging; however, it is not possible to merge the changes between the trees because they are from separate modules in a previous CVS repository.
I'd like to use the SVN Copy (or SVN move) commands to be able to track the merging; however, I usually get an error that the file already exists.

Is there a way to do the svn copy/move and overwrite an existing file in the same transaction? (i.e. instead of having to go delete the file first, then do the copy/move second, do it as a single commit, or have the copy/move comit the changes between the two files as the commit..).

I wasn't able to spot any command-line options to do this, so I'm thinking it's not possible. If that is the case, it would be a really great feature to have.

TIA,

Ben

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=990024

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Dec 22, 2008, at 13:44, BRM wrote:

> I have two repository trees I am working on merging; however, it is  
> not possible to merge the changes between the trees because they  
> are from separate modules in a previous CVS repository.
> I'd like to use the SVN Copy (or SVN move) commands to be able to  
> track the merging; however, I usually get an error that the file  
> already exists.
>
> Is there a way to do the svn copy/move and overwrite an existing  
> file in the same transaction?

I don't think there's a command to overwrite an existing file  
specifically, but you can certainly delete the existing file and  
replace it with a new file or a file copied from elsewhere all in the  
same transaction.

> (i.e. instead of having to go delete the file first, then do the  
> copy/move second, do it as a single commit, or have the copy/move  
> comit the changes between the two files as the commit..).

You can either get a working copy of the repository and do the delete  
and move there before committing:

$ svn checkout $REPO_URL wc
$ cd wc
$ svn delete foo/myfile
$ svn copy bar/myfile foo/myfile
$ svn commit -m "replacing foo/myfile with bar/myfile"

Or if you want to do everything with repository URLs without a  
working copy, then you can use the svnmucc command line client  
instead of the usual svn command line client. I don't have an example  
handy but here's its usage message:


$ svnmucc
Multiple URL Command Client (for Subversion)

Usage: svnmucc [OPTION]... [ACTION]...

Actions:
   cp REV URL1 URL2      copy URL1@REV to URL2
   mkdir URL             create new directory URL
   mv URL1 URL2          move URL1 to URL2
   rm URL                delete URL
   put SRC-FILE URL      add or modify file URL with contents copied
                         from SRC-FILE
   propset NAME VAL URL  Set property NAME on URL to value VAL
   propdel NAME URL      Delete property NAME from URL

Options:
   -h, --help            display this text
   -m, --message ARG     use ARG as a log message
   -F, --file ARG        read log message from file ARG
   -u, --username ARG    commit the changes as username ARG
   -p, --password ARG    use ARG as the password
   -U, --root-url ARG    interpret all action URLs are relative to ARG
   -r, --revision ARG    use revision ARG as baseline for changes
   -n, --non-interactive don't prompt the user about anything
   -X, --extra-args ARG  append arguments from file ARG (one per line;
                         use "-" to read from standard input)
   --config-dir ARG      use ARG to override the config directory

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=990449

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by km...@rockwellcollins.com.
Ryan Schmidt <su...@ryandesign.com> wrote on 12/26/2008 
03:23:45 PM:
> On Dec 26, 2008, at 09:02, BRM wrote:
> > Ok, but is there a single command that does both operations so I 
> > don't have to do it in two steps? I'd really like to just do it in 
> > one step.
> 
> You can issue a single svnmucc command, but you will have to pass 
> svnmucc the two subcommands you want to do (remove the one thing, 
> copy the other thing). They are separate Subversion operations.

I have on my to-do list a new svnmucc command to "copy and overwrite
if it exists".  There was some concern it wasn't needed, since as
stated, you can script to check if it exists and then delete, but
this runs into a big race condition.

> > If not, I think it would make a great feature to add an option to 
> > the move/copy to be able to make it do it in one step (example: -- 
> > remove-file-first, --overwrite, --force).
> 
> You can probably write a small script to do this for you if you plan 
> to do it often and don't want to keep typing two commands each time.

Funny thing is, internally, Subversion converts a "Copy and Delete"
in the same transaction as a "replace" operation, so it is already
capable of this, it just doesn't expose the functionality via
the command line interface...

Kevin R.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=998755

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Dec 26, 2008, at 09:02, BRM wrote:

> Ok, but is there a single command that does both operations so I  
> don't have to do it in two steps? I'd really like to just do it in  
> one step.

You can issue a single svnmucc command, but you will have to pass  
svnmucc the two subcommands you want to do (remove the one thing,  
copy the other thing). They are separate Subversion operations.

> If not, I think it would make a great feature to add an option to  
> the move/copy to be able to make it do it in one step (example: -- 
> remove-file-first, --overwrite, --force).

You can probably write a small script to do this for you if you plan  
to do it often and don't want to keep typing two commands each time.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=993286

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by BRM <bm...@yahoo.com>.
Ok, but is there a single command that does both operations so I don't have to do it in two steps? I'd really like to just do it in one step.
If not, I think it would make a great feature to add an option to the move/copy to be able to make it do it in one step (example: --remove-file-first, --overwrite, --force).

Ben



----- Original Message ----
From: Dave Lawrence <dl...@ad-holdings.co.uk>
To: BRM <bm...@yahoo.com>
Cc: users@subversion.tigris.org
Sent: Tuesday, December 23, 2008 2:38:35 AM
Subject: Re: SVN Copy Question...

BRM wrote:
> 
> Is there a way to do the svn copy/move and overwrite an existing file in the same transaction? (i.e. instead of having to go delete the file first, then do the copy/move second, do it as a single commit, or have the copy/move comit the changes between the two files as the commit..).
> 
Yes because you don't have to commit the deletion before you commit the
copy / move.

eg:
> C:\SVN\tests\test_wc2\dir1>svn del file1.c
> D         file1.c
> 
> C:\SVN\tests\test_wc2\dir1>svn mv file2.c file1.c
> A         file1.c
> D         file2.c
> 
> C:\SVN\tests\test_wc2\dir1>svn status
> R  +    file1.c
> D       file2.c

R + indicates file1 has been replaced.  Note that after you commit it,
the "new" file1.c will have the history of file2.c

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=990417

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=992961

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by Dave Lawrence <dl...@ad-holdings.co.uk>.
BRM wrote:
> 
> Is there a way to do the svn copy/move and overwrite an existing file in the same transaction? (i.e. instead of having to go delete the file first, then do the copy/move second, do it as a single commit, or have the copy/move comit the changes between the two files as the commit..).
> 
Yes because you don't have to commit the deletion before you commit the
copy / move.

eg:
> C:\SVN\tests\test_wc2\dir1>svn del file1.c
> D         file1.c
> 
> C:\SVN\tests\test_wc2\dir1>svn mv file2.c file1.c
> A         file1.c
> D         file2.c
> 
> C:\SVN\tests\test_wc2\dir1>svn status
> R  +    file1.c
> D       file2.c

R + indicates file1 has been replaced.  Note that after you commit it,
the "new" file1.c will have the history of file2.c

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=990417

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

Re: SVN Copy Question...

Posted by BRM <bm...@yahoo.com>.
But I don't want to install a separate package for something that should be a native command option.

There is no reason why it should have to two separate commands, so long as the option is available - even if it provides a confirmation warning during the process (probably should). But it should be a native part of the SVN package, not relayed to a secondary tool set, which even though svnmucc is part of the SVN source tree I would argue it is still a secondary tool since it is not part of the standard installation, nor is it provided by the CollabNet SVN Windows Installer - so no luck here unless I go build my own copy of SVN.

Yes, I could script it, but there is no reason I should have to when a simple command-line option for the standard 'svn copy/move' operation would suffice. Why should everyone have to script something that is a standard file operation?  (e.g. 'cp/copy/mv' will prompt to overwrite a file, not force you to delete the file first. I realize SVN is a versioning system, but this should still be a single operation for the user, even if the tool performs the single operation as two separate operations internally.)

Ben



----- Original Message ----
From: Ryan Schmidt <su...@ryandesign.com>
To: BRM <bm...@yahoo.com>
Cc: users@subversion.tigris.org
Sent: Friday, December 26, 2008 4:23:45 PM
Subject: Re: SVN Copy Question...

On Dec 26, 2008, at 09:02, BRM wrote:

> Ok, but is there a single command that does both operations so I  
> don't have to do it in two steps? I'd really like to just do it in  
> one step.

You can issue a single svnmucc command, but you will have to pass  
svnmucc the two subcommands you want to do (remove the one thing,  
copy the other thing). They are separate Subversion operations.

> If not, I think it would make a great feature to add an option to  
> the move/copy to be able to make it do it in one step (example: -- 
> remove-file-first, --overwrite, --force).

You can probably write a small script to do this for you if you plan  
to do it often and don't want to keep typing two commands each time.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=993286

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=995066

To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].