You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by pm...@users.sourceforge.net on 2003/10/16 12:44:06 UTC

how to update a file's copy in another directory

Hello everybody,

I'd like to know how to handle the following case.
(But beware: I'm still using 0.25, and this may be the problem)

I have a file in several versions, and I needed a copy of an older version in 
another directory.
So I did a "svn cp -r OLD URL/file newdir" - so "svn log -v" shows
	A file (from olddir/file).

So far, so good.

But now I've come to the conclusion that I need another version of this file 
in the new directory.
- "svn cp" as above says "item exists" (which it does - cp is an add with 
history)
- "svn up" says that this element didn't exist in that revision (which is 
correct, too - since the secondary directory was created some revisions 
later)
- "svn co -r olddir/file file" (standing in new-dir) says "obstructed update" 
and "'' is already a wc for a different url"

So, what can I do??


I did checkout this file to a completly different wc and just copied the file 
in the new-dir.
But that is not the best way - since the same data is already present in the 
db...


But maybe that just a problem of 0.25??


Thanks for all answers!!!


Regards,

P.Marek


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

Re: how to update a file's copy in another directory

Posted by Ben Collins-Sussman <su...@collab.net>.
pmarek@users.sourceforge.net writes:

> # how can I get dir2/file to be dir1/file revision 2?

> #  svn up -r 2 dir2/file
> #> svn: Filesystem has no item
> #> svn: file not found: revision `2', path `/dir2'

This won't work, because 'svn up' only moves through revisions (time).

But its cousin, 'svn switch', moves through revisions (time) *and*
paths (space.)

So something like

    svn switch -r2 http://.../dir1/file dir2/file

Now you have a working copy with 'mixed' URLs.  You've essentially
moved the one file to a different branch.  This will give what you
want, at least temporarily.

Unfortunately, because it's an *old* version of the branch (r2), if
you run 'svn up' on the whole working copy, it will try to update
dir2/file to the latest revision of dir1/file (i.e. move it forward in
time, without changing the file's URL.)  There's no way to make it
'sticky'.

> 
> #  svn cp -r 2 dir1/file dir2/file
> #> svn: Entry already exists
> #> svn: file `dir2/file' already exists.

Correct.  'svn cp' will never overwrite anything.

> #  svn co -r2  file:///home/p107/test/svn/data.20548/repos/dir1/file dir2/
> #> svn: Obstructed update
> #> svn: 'dir2' is already a working copy for a different url

You can't checkout a foreign URL into a working copy of a different
URL.

> I believe that I can delete the file and cp another revision - but that's
> 2 new revisions instead of 1 :-)

That's the only solution.  If you want the change to be *permanent*,
you have to "replace" the file (delete file, add new one).  And it can
be done in a single commit:

 $  svn rm dir2/file
 $  svn cp -r2 http://.../dir1/file dir2/file
 $  svn status
 R +   dir2/file   # the 'R' is for (R)eplace

 $  svn commit



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

Re: how to update a file's copy in another directory

Posted by pm...@users.sourceforge.net.
> pmarek@users.sourceforge.net writes:
> > Hello everybody,
> >
> > I'd like to know how to handle the following case.
> > (But beware: I'm still using 0.25, and this may be the problem)
>
> Can you send an exact transcript of what you're typing?  It's very
> hard for me to understand what you're doing just by your verbal
> descriptions.

here comes the script:

#!/bin/bash

DATA=`pwd`/data.$$

# initialization

mkdir $DATA
cd $DATA

svnadmin create --bdb-txn-nosync repos
svn co file://$DATA/repos wc
cd wc

svn mkdir dir1
echo A > dir1/file
svn add dir1/file

for x in A B C D E F G
do
echo $x > dir1/file
svn ci -m "to $x"
done


# Now I'd like to have a copy of dir1/file revision 4 in dir2

svn mkdir dir2
svn cp -r 4 dir1/file dir2/file
svn ci -m "with dir2/file from 4"

# so far, so good.

# The problem:
#-------------

# how can I get dir2/file to be dir1/file revision 2?


# I tried:

#  svn up -r 2 dir2/file
#> svn: Filesystem has no item
#> svn: file not found: revision `2', path `/dir2'

#  svn cp -r 2 dir1/file dir2/file
#> svn: Entry already exists
#> svn: file `dir2/file' already exists.

#  svn co -r2  file:///home/p107/test/svn/data.20548/repos/dir1/file dir2/
#> svn: Obstructed update
#> svn: 'dir2' is already a working copy for a different url


I believe that I can delete the file and cp another revision - but that's
2 new revisions instead of 1 :-)

Maybe something could be done with "svn merge"?

Although I believe that since svn has complete historical information about 
this file it should be possible to get any revision of this "entitity", 
regardless about where it is "hard-linked". 
I take a unix-filesystem as base, so that a "file" is only a name for an 
entity - and especially in svn, just because an "entity" has no "name" (no 
incarnation) in a given revision that doesn't mean that it doesn't exist 
anymore - it is just not "visible" by name.



Thanks for all hints.


Regards,

P.Marek


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

Re: how to update a file's copy in another directory

Posted by Ben Collins-Sussman <su...@collab.net>.
pmarek@users.sourceforge.net writes:

> Hello everybody,
> 
> I'd like to know how to handle the following case.
> (But beware: I'm still using 0.25, and this may be the problem)

Can you send an exact transcript of what you're typing?  It's very
hard for me to understand what you're doing just by your verbal
descriptions.

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