You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Francois Beausoleil <fb...@users.sourceforge.net> on 2003/07/24 18:30:23 UTC

[PATCH] cvs2svn.py - Always return / in make_path()

Hi !

This is a patch to be able to use cvs2svn.py on Win32.  This patch
converts from backslashes to forward-slashes, which SVN expects.

LOG:
* tools/cvs2svn/cvs2svn.py (make_path):
  Convert from using platform default path separator to forward slashes
  in all cases.  If left alone, conversion on Win32 would generate
  filenames with forward slashes in them, which could not be checked
  out.  svnshell.py would also be unable to cat the file's content.

Index: cvs2svn.py
===================================================================
--- cvs2svn.py  (revision 6562)
+++ cvs2svn.py  (working copy)
@@ -77,6 +77,12 @@
 # official restrictions anyway).
 symbolic_name_re = re.compile('^[a-zA-Z][^/\\\\]*$')
 
+# A regular expression to split a path that contains both forward and
back
+# slashes.  This is important on Win32 because the paths will use the
+# platform default, but SVN must receive forward slashes.  See the
+# make_path() return value for more information on usage.
+slash_split_re = re.compile("/\\\\|\\\\|:")
+
 class CollectData(rcsparse.Sink):
   def __init__(self, cvsroot, log_fname_base):
     self.cvsroot = cvsroot
@@ -306,20 +312,22 @@
 
   if branch_name:
     if path:
-      return ctx.branches_base + '/' + branch_name + '/' + path
+      target_path = ctx.branches_base + '/' + branch_name + '/' + path
     else:
-      return ctx.branches_base + '/' + branch_name
+      target_path = ctx.branches_base + '/' + branch_name
   elif tag_name:
     if path:
-      return ctx.tags_base + '/' + tag_name + '/' + path
+      target_path = ctx.tags_base + '/' + tag_name + '/' + path
     else:
-      return ctx.tags_base + '/' + tag_name
+      target_path = ctx.tags_base + '/' + tag_name
   else:
     if path:
-      return ctx.trunk_base + '/' + path
+      target_path = ctx.trunk_base + '/' + path
     else:
-      return ctx.trunk_base
+      target_path = ctx.trunk_base
 
+  # Convert from back-slashes to forward-slashes
+  return string.join(slash_split_re.split(target_path), "/")
 
 def relative_name(cvsroot, fname):
   l = len(cvsroot)
Developer of Java Gui Builder
http://jgb.sourceforge.net/

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