[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: cvs2svn change_path crash - Windows

From: Martin Fuchs <martin-fuchs_at_gmx.net>
Date: 2003-09-12 22:32:18 CEST

Russell Yanofsky wrote:

> I see that you changed the implementation of relative_name from:
>
> def relative_name(cvsroot, fname):
> l = len(cvsroot)
> assert fname[:l] == cvsroot and fname[l] == os.sep
> return string.replace(fname[l+1:], os.sep, '/')
>
> to
>
> def relative_name(cvsroot, fname):
> l = len(cvsroot)
> if fname[:l] == cvsroot:
> if fname[l] == os.sep:
> return string.replace(fname[l+1:], os.sep, '/')
> return string.replace(fname[l:], os.sep, '/')
> sys.stderr.write('relative_path("%s", "%s"): fname is not a sub-path of'
> ' cvsroot\n' % (cvsroot, fname))
> sys.exit(1)
>
> I'm not sure why though. If fname[l] is not the seperator character, then
> that either means that fname[l:] is the empty string, making the second
> replace operation unneccessary, or that fname begins with a path other than
> the cvsroot, which means an error should be thrown. Was this change actually
> needed to get the patch to run with the new code?

Well, I only tried to merge the changes, which were commited at this code place after the uinitial revision, you used for your last path version. I had to merge by hand, because 'patch' could not resolve the conflict.

> Also I think that using an assertion is a more appropriate way of handling
> this error than calling sys.exit because the only thing that can cause it to
> be triggered is programmer error (incorrect usage of the relative_name
> function).

The conflicting patch of Max at this code position has been the following:

------------------------------------------------------------------------
rev 6816: kfogel | 2003-08-21 17:50:34 +0200 (Thu, 21 Aug 2003) | 6 lines

Apply patch from "Max Bowsher" <maxb@ukf.net>:

* tools/cvs2svn/cvs2svn.py
  (relative_name): If fname is not a subpath of cvsroot, then actually
    error, instead of returning garbage.

------------------------------------------------------------------------

Index: cvs2svn.py
===================================================================
--- cvs2svn.py (revision 6815)
+++ cvs2svn.py (revision 6816)
@@ -326,7 +326,9 @@
     if fname[l] == '/':
       return fname[l+1:]
     return fname[l:]
- return l
+ sys.stderr.write('relative_path("%s", "%s"): fname is not a sub-path of'
+ ' cvsroot\n' % (cvsroot, fname))
+ sys.exit(1)

 def visit_file(arg, dirname, files):

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Sep 12 23:01:44 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.