You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Jojakim Stahl <JS...@demig.de> on 2003/09/11 08:15:55 UTC

Is there a replace or copy with replace command

I want to replace a item in the repos with another one. That ist performing
a delete followed by a copy in one transaction, all directly within the
repos.

Example:
Within the repos, the following two dirs exist:
root/dir1/contents_of_dir1
root/dir2/contents_of_dir1

I want to overwrite dir2 with dir1. Tried with
svn copy root/dir1 root/dir2 -m "Try to replace dir2 by dir1"

What happens is:
root/dir1/contents_of_dir1
root/dir2/contents_of_dir2
root/dir2/dir1/contents_of_dir1

But I just wanted to replace dir2:
root/dir1/contents_of_dir1
root/dir2/contents_of_dir1

Any solution?

Thanx, Joja


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

Re: Is there a replace or copy with replace command

Posted by Ben Collins-Sussman <su...@collab.net>.
Philip Martin <ph...@codematters.co.uk> writes:

> So an item that is schedule delete can be replaced by 'svn add' but
> not by 'svn copy'.  Odd.

Very odd.  You want to file an issue with these recipes?

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

Re: Is there a replace or copy with replace command

Posted by Philip Martin <ph...@codematters.co.uk>.
Philip Martin <ph...@codematters.co.uk> writes:

> Ben Collins-Sussman <su...@collab.net> writes:
>
>> But I thought maybe I could do it in a single transaction, using the
>> 'replace' action in the working copy.  I ran these commands:
>>
>> $ svn rm dir2
>> $ rm -rf dir2
>
> Sneaky!  Is that breaking the rules?
>
>> $ svn cp dir1 dir2

Trying this with files gives

$ svn cp wc/zag wc/zig
../svn/subversion/libsvn_wc/copy.c:156: (apr_err=150002)
svn: Entry already exists
svn: 'wc/zig' is scheduled for deletion, it must be commited before being overwritten

which looks like the same limitation that we have for directories,
with the difference that it is caught at the copy stage rather than
the commit stage.

However, for files this works

$ svn rm wc/zig
$ touch wc/zig
$ svn add wc/zig
$ svn ci wc

and for directories this works

$ svn rm wc/zig
$ svn add wc/zig
$ svn ci wc

So an item that is schedule delete can be replaced by 'svn add' but
not by 'svn copy'.  Odd.

-- 
Philip Martin

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

Re: Is there a replace or copy with replace command

Posted by Philip Martin <ph...@codematters.co.uk>.
Ben Collins-Sussman <su...@collab.net> writes:

> But I thought maybe I could do it in a single transaction, using the
> 'replace' action in the working copy.  I ran these commands:
>
> $ svn rm dir2
> $ rm -rf dir2

Sneaky!  Is that breaking the rules?

> $ svn cp dir1 dir2
>
> ...at this point, 'svn st' shows 'A +  dir2', and the entry claims
> that dir2 is 'schedule=replace' with copy-history.
>
> But when I try to commit the replacement, I get an out-of-date error
> on dir2.  I'm not sure why.  
>
> Philip, any ideas?  Maybe this is a bug?

$ svnadmin create repo
$ svn mkdir file://`pwd`/repo/zig file://`pwd`/repo/zag -m ""
$ svn co file://`pwd`/repo wc
$ svn rm wc/zig
$ rm -rf wc/zig
$ svn mv wc/zag wc/zig
$ svn st wc
D      wc/zag
A  +   wc/zig
$ svn ci wc
Deleting       wc/zag
Adding         wc/zig

It's attempting to add the new zig before deleting the original zig.

../svn/subversion/libsvn_client/commit.c:727: (apr_err=160028)
svn: Transaction is out of date
svn: Commit failed (details follow):
../svn/subversion/libsvn_repos/commit.c:114: (apr_err=160028)
svn: out of date: `zig' in txn `a'
../svn/subversion/clients/cmdline/util.c:363: (apr_err=160028)
svn: Your commit message was left in a temporary file:
../svn/subversion/clients/cmdline/util.c:364: (apr_err=160028)
svn:    '/home/pm/sw/subversion/obj/wc/svn-commit.8.tmp'

We get out of date because there is already an item with the same
name.

-- 
Philip Martin

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

Re: Is there a replace or copy with replace command

Posted by Ben Collins-Sussman <su...@collab.net>.
"Jojakim Stahl" <JS...@demig.de> writes:

> I want to replace a item in the repos with another one. That ist performing
> a delete followed by a copy in one transaction, all directly within the
> repos.

'svn cp' works the same way as unix cp:  it doesn't overwrite
directories.  It creates a new directory within an existing one.

It's certainly easy to do what you want in *two* commits:  just delete
the first directory, then copy the 1st directory to the same location.

But I thought maybe I could do it in a single transaction, using the
'replace' action in the working copy.  I ran these commands:

$ svn rm dir2
$ rm -rf dir2
$ svn cp dir1 dir2

...at this point, 'svn st' shows 'A +  dir2', and the entry claims
that dir2 is 'schedule=replace' with copy-history.

But when I try to commit the replacement, I get an out-of-date error
on dir2.  I'm not sure why.  

Philip, any ideas?  Maybe this is a bug?


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