changeset 7075:6db6f6db026a

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Fri, 10 Oct 2008 13:20:40 +0200
parents 4e0d54fbd34f (current diff) b1a4f67b98d0 (diff)
children c29d3f4ed967
files hgext/convert/common.py hgext/convert/subversion.py
diffstat 5 files changed, 40 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/common.py	Thu Oct 09 14:16:17 2008 +0200
+++ b/hgext/convert/common.py	Fri Oct 10 13:20:40 2008 +0200
@@ -2,7 +2,7 @@
 import base64, errno
 import os
 import cPickle as pickle
-from mercurial import util
+from mercurial import util, strutil
 from mercurial.i18n import _
 
 def encodeargs(args):
@@ -332,7 +332,7 @@
                 raise
             return
         for line in fp:
-            key, value = line[:-1].split(' ', 1)
+            key, value = strutil.rsplit(line[:-1], ' ', 1)
             if key not in self:
                 self.order.append(key)
             super(mapfile, self).__setitem__(key, value)
--- a/hgext/convert/subversion.py	Thu Oct 09 14:16:17 2008 +0200
+++ b/hgext/convert/subversion.py	Fri Oct 10 13:20:40 2008 +0200
@@ -21,6 +21,7 @@
 import sys
 import cPickle as pickle
 import tempfile
+import urllib
 
 from mercurial import strutil, util
 from mercurial.i18n import _
@@ -54,7 +55,7 @@
         path = os.path.normpath(os.path.abspath(path))
         if os.name == 'nt':
             path = '/' + util.normpath(path)
-        return 'file://%s' % path
+        return 'file://%s' % urllib.quote(path)
     return path
 
 def optrev(number):
@@ -172,10 +173,10 @@
             self.transport = transport.SvnRaTransport(url=self.url)
             self.ra = self.transport.ra
             self.ctx = self.transport.client
-            self.base = svn.ra.get_repos_root(self.ra)
+            self.baseurl = svn.ra.get_repos_root(self.ra)
             # Module is either empty or a repository path starting with
             # a slash and not ending with a slash.
-            self.module = self.url[len(self.base):]
+            self.module = urllib.unquote(self.url[len(self.baseurl):])
             self.prevmodule = None
             self.rootmodule = self.module
             self.commits = {}
@@ -230,7 +231,7 @@
 
     def exists(self, path, optrev):
         try:
-            svn.client.ls(self.url.rstrip('/') + '/' + path,
+            svn.client.ls(self.url.rstrip('/') + '/' + urllib.quote(path),
                                  optrev, False, self.ctx)
             return True
         except SubversionException, err:
@@ -279,8 +280,8 @@
         # Check if branches bring a few more heads to the list
         if branches:
             rpath = self.url.strip('/')
-            branchnames = svn.client.ls(rpath + '/' + branches, rev, False,
-                                        self.ctx)
+            branchnames = svn.client.ls(rpath + '/' + urllib.quote(branches), 
+                                        rev, False, self.ctx)
             for branch in branchnames.keys():
                 module = '%s/%s/%s' % (oldmodule, branches, branch)
                 if not isdir(module, self.last_changed):
@@ -324,8 +325,8 @@
         else:
             # Perform a full checkout on roots
             uuid, module, revnum = self.revsplit(rev)
-            entries = svn.client.ls(self.base + module, optrev(revnum),
-                                    True, self.ctx)
+            entries = svn.client.ls(self.baseurl + urllib.quote(module), 
+                                    optrev(revnum), True, self.ctx)
             files = [n for n,e in entries.iteritems()
                      if e.kind == svn.core.svn_node_file]
             copies = {}
@@ -524,12 +525,12 @@
         """Reparent the svn transport and return the previous parent."""
         if self.prevmodule == module:
             return module
-        svn_url = (self.base + module).encode(self.encoding)
+        svnurl = self.baseurl + urllib.quote(module)
         prevmodule = self.prevmodule
         if prevmodule is None:
             prevmodule = ''
-        self.ui.debug(_("reparent to %s\n") % svn_url)
-        svn.ra.reparent(self.ra, svn_url)
+        self.ui.debug(_("reparent to %s\n") % svnurl)
+        svn.ra.reparent(self.ra, svnurl)
         self.prevmodule = module
         return prevmodule
 
@@ -870,8 +871,9 @@
     def _find_children(self, path, revnum):
         path = path.strip('/')
         pool = Pool()
-        rpath = '/'.join([self.base, path]).strip('/')
-        return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
+        rpath = '/'.join([self.baseurl, urllib.quote(path)]).strip('/')
+        return ['%s/%s' % (path, x) for x in 
+                svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
 
     def getrelpath(self, path, module=None):
         if module is None:
@@ -907,7 +909,7 @@
             if not p.startswith('/'):
                 p = self.module + '/' + p
             relpaths.append(p.strip('/'))
-        args = [self.base, relpaths, start, end, limit, discover_changed_paths,
+        args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths,
                 strict_node_history]
         arg = encodeargs(args)
         hgexe = util.hgexecutable()
--- a/mercurial/strutil.py	Thu Oct 09 14:16:17 2008 +0200
+++ b/mercurial/strutil.py	Fri Oct 10 13:20:40 2008 +0200
@@ -32,3 +32,10 @@
             break
         yield c
         end = c - 1
+
+def rsplit(s, sep=None, maxsplit=-1):
+    try:
+        return s.rsplit(sep, maxsplit)
+    except AttributeError:
+        return  [chunk[::-1] for chunk in 
+                 s[::-1].split(sep, maxsplit)[::-1]]
--- a/tests/test-convert-svn-source	Thu Oct 09 14:16:17 2008 +0200
+++ b/tests/test-convert-svn-source	Fri Oct 10 13:20:40 2008 +0200
@@ -30,23 +30,23 @@
 mkdir tags
 cd ..
 
-svnurl=file://$svnpath/svn-repo/projB
+svnurl=file://$svnpath/svn-repo/proj%20B
 svn import -m "init projB" projB $svnurl | fix_path
 
 
 echo % update svn repository
 svn co $svnurl/trunk B | fix_path
 cd B
-echo hello > letter.txt
-svn add letter.txt
+echo hello > 'letter .txt'
+svn add 'letter .txt'
 svn ci -m hello
 
-"$TESTDIR/svn-safe-append.py" world letter.txt
+"$TESTDIR/svn-safe-append.py" world 'letter .txt'
 svn ci -m world
 
 svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
 
-"$TESTDIR/svn-safe-append.py" 'nice day today!' letter.txt
+"$TESTDIR/svn-safe-append.py" 'nice day today!' 'letter .txt'
 svn ci -m "nice day"
 cd ..
 
@@ -55,7 +55,7 @@
 
 echo % update svn repository again
 cd B
-"$TESTDIR/svn-safe-append.py" "see second letter" letter.txt
+"$TESTDIR/svn-safe-append.py" "see second letter" 'letter .txt'
 echo "nice to meet you" > letter2.txt
 svn add letter2.txt
 svn ci -m "second letter"
--- a/tests/test-convert-svn-source.out	Thu Oct 09 14:16:17 2008 +0200
+++ b/tests/test-convert-svn-source.out	Fri Oct 10 13:20:40 2008 +0200
@@ -7,16 +7,16 @@
 Committed revision 1.
 % update svn repository
 Checked out revision 1.
-A         letter.txt
-Adding         letter.txt
+A         letter .txt
+Adding         letter .txt
 Transmitting file data .
 Committed revision 2.
-Sending        letter.txt
+Sending        letter .txt
 Transmitting file data .
 Committed revision 3.
 
 Committed revision 4.
-Sending        letter.txt
+Sending        letter .txt
 Transmitting file data .
 Committed revision 5.
 % convert to hg once
@@ -31,7 +31,7 @@
 updating tags
 % update svn repository again
 A         letter2.txt
-Sending        letter.txt
+Sending        letter .txt
 Adding         letter2.txt
 Transmitting file data ..
 Committed revision 6.
@@ -51,15 +51,15 @@
 |
 o  6 work in progress files: letter2.txt
 |
-o  5 second letter files: letter.txt letter2.txt
+o  5 second letter files: letter .txt letter2.txt
 |
 o  4 update tags files: .hgtags
 |
-o  3 nice day files: letter.txt
+o  3 nice day files: letter .txt
 |
-o  2 world files: letter.txt
+o  2 world files: letter .txt
 |
-o  1 hello files: letter.txt
+o  1 hello files: letter .txt
 |
 o  0 init projB files: