You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by SteveKing <st...@gmx.ch> on 2004/05/12 14:38:25 UTC

relocate doesn't check arguments - may screw up working copy

Hi,

while checking some bug reports with the relocate command in TSVN I came 
across a feature in the command line client:

svn switch --relocate . http://newserver.com/

this will finish without any error (as long as newserver.com is alive), 
but check now the .svn/entries file and see what URL is stored in there!

I think the command line client should check if the "source" URL is 
actually an URL - or better yet find the URL from the working copy path.

Stefan

--
"Who the hell wants to hear actors talk?" - H. M. Warner, Warner 
Brothers, 1927.
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Ben Collins-Sussman wrote:

> I don't understand the reproduction recipe.  When I run this command, I
> just get bizarre errors with garbled URLs:
> 
> $ cd libsvn_wc
> $ svn switch --relocate . http://morbius.ch.collab.net/
> 
> subversion/libsvn_ra_dav/util.c:664: (apr_err=175002)
> svn: PROPFIND request failed on
> '//svn.collab.net/repos/svn/trunk/subversion/libsvn_wc'
> subversion/libsvn_ra_dav/util.c:287: (apr_err=175002)
> svn: PROPFIND of
> '//svn.collab.net/repos/svn/trunk/subversion/libsvn_wc': Could
> not resolve hostname `morbius.ch.collab.nethttp': Host not found
> (http://morbius.ch.collab.nethttp)

Could it be that there's no repository on that new URL?
I can reproduce it with version 1.0.2 (windows) every time, but I do 
that with relocating from
https://svn.collab.net/repos/svn/trunk/doc/book
to
http://svn.collab.net/repos/svn/trunk/doc/book
and back. Maybe that's the problem? The same repository but a different 
URL schema?

Stefan

--
"Who the hell wants to hear actors talk?" - H. M. Warner, Warner 
Brothers, 1927.
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Ben Collins-Sussman <su...@collab.net>.
On Wed, 2004-05-12 at 09:38, SteveKing wrote:
> Hi,
> 
> while checking some bug reports with the relocate command in TSVN I came 
> across a feature in the command line client:
> 
> svn switch --relocate . http://newserver.com/
> 
> this will finish without any error (as long as newserver.com is alive), 
> but check now the .svn/entries file and see what URL is stored in there!

I don't understand the reproduction recipe.  When I run this command, I
just get bizarre errors with garbled URLs:

$ cd libsvn_wc
$ svn switch --relocate . http://morbius.ch.collab.net/

subversion/libsvn_ra_dav/util.c:664: (apr_err=175002)
svn: PROPFIND request failed on
'//svn.collab.net/repos/svn/trunk/subversion/libsvn_wc'
subversion/libsvn_ra_dav/util.c:287: (apr_err=175002)
svn: PROPFIND of
'//svn.collab.net/repos/svn/trunk/subversion/libsvn_wc': Could
not resolve hostname `morbius.ch.collab.nethttp': Host not found
(http://morbius.ch.collab.nethttp)




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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Mark Benedetto King <mb...@lowlatency.com>.
On Thu, May 13, 2004 at 07:32:21AM -0500, Ben Collins-Sussman wrote:
> Mark Benedetto King wrote:
> 
> >Right now, relocate just checks that the UUIDs of the repositories are
> >the same.  What it should do is verify that the path component of
> >the URL (entry->url + strlen(ra->get_repos_root()) remains unchanged.
> 
> Should we file this as an issue?

Filed as issue 1859.

--ben


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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Ben Collins-Sussman <su...@collab.net>.
Mark Benedetto King wrote:

> Right now, relocate just checks that the UUIDs of the repositories are
> the same.  What it should do is verify that the path component of
> the URL (entry->url + strlen(ra->get_repos_root()) remains unchanged.

Should we file this as an issue?

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Ben Collins-Sussman <su...@collab.net>.
On Thu, 2004-05-13 at 11:30, Max Bowsher wrote:

> If the WC is checkout out from:
> http://some.server/path/to/repository/trunk/foo
> 
> then all of the following are valid X-es:
> http://some.server/path/to/repository/
> http://some.server/path/to/repository
> http://some.server/path/to/reposi
> http://some.server/path/to
> http://some.server/path/
> http://some.server/
> http://some
> http://
> http:

Correct.

The --relocate switch is *only* to be used when the SVNROOT changes, and
nothing else.  If you want the working copy to reflect a different path
within a repository, you must use the real 'svn switch' command to do
that.



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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Mark Benedetto King <mb...@lowlatency.com>.
On Thu, May 13, 2004 at 09:52:50PM +0200, SteveKing wrote:
> Max Bowsher wrote:
> 
> >The problem here is that Ben and I have been attempting to help you
> >to understand the current functionality whilst you seem to be 
> >simultaneously proposing new functionality.
> >
> >We can all agree that invalid input to svn switch --relocate should
> >cause an error, not break the working copy.
> >
> >If you really think that the syntax for switch --relocate should be
> >changed, it would be best to start a new thread with a more 
> >appropriate subject, as that would require discussion of the design
> >and thoughts about compatibility guarantees.
> 
> Oops. Sorry. First I just tried to think about ways how to overcome the 
> lack of sanity checking, but I guess I went a little too far and came to 
> a new feature. You're right. Sorry.
> 
> So then I'd like to propose a way to do the sanity checking:
> 
> right now, the relocate command checks if the "to" URL has the same 
> repository uuid as the working copy. You can see that in the source and 
> by trying to relocate to a nonexisting "to" URL or to a "to" URL which 
> has a completely different repository there.
> So I think it would be best if the uuid comparison isn't done with the 
> "to" URL but with the *resulting* URL of the string replacement.
> Or would that break the way this command is supposed to work?
> 
> Stefan
> 

It does check that the resulting URL is valid.  Or, at least,
it tries to.

For each new URL generated, it calls validator_func() in
libsvn_client/relocate.c, passing the old UUID and the new URL.

To avoid a new RA connection in order to test each new URL, it
uses a cached mapping of already-determined URL -> UUID pairs.
If any of the pre-resolved URLs are prefixes of the new URL,
it uses their UUID.

I haven't looked into your specific case, but my assumption
is that you're running into the same problem that would happen
if you tried to do

svn switch --relocate \
    http://svn.collab.net/repos/svn/trunk \
    http://svn.collab.net/repos/svn/branches

The switch would "succeed" because all of the computed URLs
would fall under http://svn.collab.net/repos/svn/branches,
which has the same UUID as the original URLs, but the
resulting WC would not be valid.

Do you have a different problem, or would adding path
validation (which was not possible before RA->get_repos_root()
was added) fix your issue?

--ben


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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Max Bowsher wrote:

> The problem here is that Ben and I have been attempting to help you
> to understand the current functionality whilst you seem to be 
> simultaneously proposing new functionality.
> 
> We can all agree that invalid input to svn switch --relocate should
> cause an error, not break the working copy.
> 
> If you really think that the syntax for switch --relocate should be
> changed, it would be best to start a new thread with a more 
> appropriate subject, as that would require discussion of the design
> and thoughts about compatibility guarantees.

Oops. Sorry. First I just tried to think about ways how to overcome the 
lack of sanity checking, but I guess I went a little too far and came to 
a new feature. You're right. Sorry.

So then I'd like to propose a way to do the sanity checking:

right now, the relocate command checks if the "to" URL has the same 
repository uuid as the working copy. You can see that in the source and 
by trying to relocate to a nonexisting "to" URL or to a "to" URL which 
has a completely different repository there.
So I think it would be best if the uuid comparison isn't done with the 
"to" URL but with the *resulting* URL of the string replacement.
Or would that break the way this command is supposed to work?

Stefan

--
"The whole problem with the world is that fools and fanatics are always 
so certain of themselves, but wiser people so full of doubts." - 
Bertrand Russell
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Max Bowsher <ma...@ukf.net>.
SteveKing wrote:
> Ben Collins-Sussman wrote:
>
>>> So my suggestion is that the relocate only takes one argument (the "to"
>>> URL).
>>
>> We're going in circles here.  If you ask perl to 's/X/Y/', but only give
>> Y, how is it supposed to guess at X?
>
> Ok, I'm obviously not very good at making myself clear. So I'll try to
> explain with some pseudo-code:
>
> right now, the relocate command does something like this:
> fromURL = userinput1;
> toURL = userinput2;
> svn_client_relocate(currentdirectory, fromURL, toURL);
>
> what I suggest is this:
>
> wcURL = svn_client_url_from_path(currentdirectory);
> fromURL = wcURL;
> toURL = userinput;
> svn_client_relocate(currentdirectory, fromURL, toURL);
>
> I hope this describes more clear of what I have in mind.
>
> Stefan

Stefan,

The problem here is that Ben and I have been attempting to help you to understand the current functionality whilst you seem to be
simultaneously proposing new functionality.

We can all agree that invalid input to svn switch --relocate should cause an error, not break the working copy.

If you really think that the syntax for switch --relocate should be changed, it would be best to start a new thread with a more
appropriate subject, as that would require discussion of the design and thoughts about compatibility guarantees.

Max.


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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Ben Collins-Sussman wrote:

>>So my suggestion is that the relocate only takes one argument (the "to" 
>>URL).
> 
> We're going in circles here.  If you ask perl to 's/X/Y/', but only give
> Y, how is it supposed to guess at X?

Ok, I'm obviously not very good at making myself clear. So I'll try to 
explain with some pseudo-code:

right now, the relocate command does something like this:
fromURL = userinput1;
toURL = userinput2;
svn_client_relocate(currentdirectory, fromURL, toURL);

what I suggest is this:

wcURL = svn_client_url_from_path(currentdirectory);
fromURL = wcURL;
toURL = userinput;
svn_client_relocate(currentdirectory, fromURL, toURL);

I hope this describes more clear of what I have in mind.

Stefan

--
Save water. Shower with your girlfriend.
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Ben Collins-Sussman wrote:

>> But you would have to specify the full URL to the new repository 
>>for that to work:
>>svn switch --relocate http://server2.com/repos
>>would then read the "from" URL from the working copy where the command 
>>was executed and substitute that with the "to" URL.
> 
> 
> This is bad and dangerous:  we cannot just assume X is the entire URL
> stored in the working copy.  If the user accidentally types the full Y
> URL incorrectly, then they may end up changing the 2nd half of the URL,
> when they only meant to change the 1st half.

AFAIK if the full Y URL is incorrect, then the command will fail anyway 
since it can't contact the new repository. Just try the relocate with a 
"to" URL which doesn't have a repository or where the server isn't 
reachable.

Stefan

--
It's not the fall that kills you: it's the sudden stop - Down by Law, 
Jim Jamursch (1986)
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Ben Collins-Sussman <su...@collab.net>.
On Thu, 2004-05-13 at 11:40, SteveKing wrote:

> I did read it carefully :)
> This is usefull if you don't want to specify the complete URL for the 
> relocate. So if the server changes from http://server1.com/repos/ to 
> http://server2.com/repos/ you could do
> svn switch --relocate http://server1 http://server2
> to relocate your working copy. 

Correct.


> But as I already mentioned, if you do a
> svn switch --relocate . http://server2.com/repos/
> you will end up with a working copy which points to a crippled URL.

This is obviously a bug;  we're not doing enough sanity checking.

> 
> So my suggestion is that the relocate only takes one argument (the "to" 
> URL).

We're going in circles here.  If you ask perl to 's/X/Y/', but only give
Y, how is it supposed to guess at X?

>  But you would have to specify the full URL to the new repository 
> for that to work:
> svn switch --relocate http://server2.com/repos
> would then read the "from" URL from the working copy where the command 
> was executed and substitute that with the "to" URL.

This is bad and dangerous:  we cannot just assume X is the entire URL
stored in the working copy.  If the user accidentally types the full Y
URL incorrectly, then they may end up changing the 2nd half of the URL,
when they only meant to change the 1st half.



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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Max Bowsher wrote:

> Read Ben's reply carefully.
> 
> To clarify:
> 
> If the WC is checkout out from:
> http://some.server/path/to/repository/trunk/foo
> 
> then all of the following are valid X-es:
> http://some.server/path/to/repository/
> http://some.server/path/to/repository
> http://some.server/path/to/reposi
> http://some.server/path/to
> http://some.server/path/
> http://some.server/
> http://some
> http://
> http:

I did read it carefully :)
This is usefull if you don't want to specify the complete URL for the 
relocate. So if the server changes from http://server1.com/repos/ to 
http://server2.com/repos/ you could do
svn switch --relocate http://server1 http://server2
to relocate your working copy. But as I already mentioned, if you do a
svn switch --relocate . http://server2.com/repos/
you will end up with a working copy which points to a crippled URL.

So my suggestion is that the relocate only takes one argument (the "to" 
URL). But you would have to specify the full URL to the new repository 
for that to work:
svn switch --relocate http://server2.com/repos
would then read the "from" URL from the working copy where the command 
was executed and substitute that with the "to" URL.

Stefan


--
Love is photosensitive. It needs darkness to develop.
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Max Bowsher <ma...@ukf.net>.
SteveKing wrote:
> Ben Collins-Sussman wrote:
> 
>> On Thu, 2004-05-13 at 10:59, SteveKing wrote:
>> 
>> 
>>> I was wondering why the --relocate command needs two URL's. The command
>>> needs to be executed inside a working copy so it knows where to start -
>>> so why does it need a "from" URL? It could read that URL from the
>>> working copy - or am I completely wrong here?
>> 
>> 
>> Because --relocate is just running a mindless textual substitution,
>> something like  s/X/Y/ on each URL.  You need to specify X and Y.
>> 
>> X might be "http://" and Y might be "svn://".   Or X might be
>> "http://oldhostname" and Y might be "http://newhostname".  Or X might be
>> "http://host/oldreposlocation" and Y might be
>> "http://host/newreposlocation".
> 
> I figured that from the URL's I got when I used the command wrong. But
> isn't the X URL always the URL the working copy is checked out from? So
> X could be read out from the working copy. Or is there another use for
> the relocate command?

Read Ben's reply carefully.

To clarify:

If the WC is checkout out from:
http://some.server/path/to/repository/trunk/foo

then all of the following are valid X-es:
http://some.server/path/to/repository/
http://some.server/path/to/repository
http://some.server/path/to/reposi
http://some.server/path/to
http://some.server/path/
http://some.server/
http://some
http://
http:



Max.



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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Ben Collins-Sussman wrote:

> On Thu, 2004-05-13 at 10:59, SteveKing wrote:
> 
> 
>>I was wondering why the --relocate command needs two URL's. The command 
>>needs to be executed inside a working copy so it knows where to start - 
>>so why does it need a "from" URL? It could read that URL from the 
>>working copy - or am I completely wrong here?
> 
> 
> Because --relocate is just running a mindless textual substitution,
> something like  s/X/Y/ on each URL.  You need to specify X and Y.  
> 
> X might be "http://" and Y might be "svn://".   Or X might be
> "http://oldhostname" and Y might be "http://newhostname".  Or X might be
> "http://host/oldreposlocation" and Y might be
> "http://host/newreposlocation".

I figured that from the URL's I got when I used the command wrong. But 
isn't the X URL always the URL the working copy is checked out from? So 
X could be read out from the working copy. Or is there another use for 
the relocate command?

Stefan

--
Every man should marry. After all, happiness is not the only thing in life.
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Ben Collins-Sussman <su...@collab.net>.
On Thu, 2004-05-13 at 10:59, SteveKing wrote:

> I was wondering why the --relocate command needs two URL's. The command 
> needs to be executed inside a working copy so it knows where to start - 
> so why does it need a "from" URL? It could read that URL from the 
> working copy - or am I completely wrong here?

Because --relocate is just running a mindless textual substitution,
something like  s/X/Y/ on each URL.  You need to specify X and Y.  

X might be "http://" and Y might be "svn://".   Or X might be
"http://oldhostname" and Y might be "http://newhostname".  Or X might be
"http://host/oldreposlocation" and Y might be
"http://host/newreposlocation".



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

Re: relocate doesn't check arguments - may screw up working copy

Posted by SteveKing <st...@gmx.ch>.
Mark Benedetto King wrote:
>>while checking some bug reports with the relocate command in TSVN I came 
>>across a feature in the command line client:
>>
>>svn switch --relocate . http://newserver.com/
>>
>>this will finish without any error (as long as newserver.com is alive), 
>>but check now the .svn/entries file and see what URL is stored in there!
>>
>>I think the command line client should check if the "source" URL is 
>>actually an URL - or better yet find the URL from the working copy path.
>>
>>Stefan
>>
> 
> 
> Right now, relocate just checks that the UUIDs of the repositories are
> the same.  What it should do is verify that the path component of
> the URL (entry->url + strlen(ra->get_repos_root()) remains unchanged.

I was wondering why the --relocate command needs two URL's. The command 
needs to be executed inside a working copy so it knows where to start - 
so why does it need a "from" URL? It could read that URL from the 
working copy - or am I completely wrong here?

Stefan


--
I feel like I'm diagonally parked in a parallel universe
--

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

Re: relocate doesn't check arguments - may screw up working copy

Posted by Mark Benedetto King <mb...@lowlatency.com>.
On Wed, May 12, 2004 at 04:38:25PM +0200, SteveKing wrote:
> Hi,
> 
> while checking some bug reports with the relocate command in TSVN I came 
> across a feature in the command line client:
> 
> svn switch --relocate . http://newserver.com/
> 
> this will finish without any error (as long as newserver.com is alive), 
> but check now the .svn/entries file and see what URL is stored in there!
> 
> I think the command line client should check if the "source" URL is 
> actually an URL - or better yet find the URL from the working copy path.
> 
> Stefan
> 

Right now, relocate just checks that the UUIDs of the repositories are
the same.  What it should do is verify that the path component of
the URL (entry->url + strlen(ra->get_repos_root()) remains unchanged.

--ben


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