convert: tolerate embedded spaces in filemap source revisions
authorPatrick Mezard <pmezard@gmail.com>
Fri, 10 Oct 2008 11:32:38 +0200
changeset 7073 af1117f37fa7
parent 7063 be2daa324ddf
child 7074 b1a4f67b98d0
convert: tolerate embedded spaces in filemap source revisions
hgext/convert/common.py
mercurial/strutil.py
--- a/hgext/convert/common.py	Fri Oct 03 23:13:03 2008 +0200
+++ b/hgext/convert/common.py	Fri Oct 10 11:32:38 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):
@@ -334,7 +334,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/mercurial/strutil.py	Fri Oct 03 23:13:03 2008 +0200
+++ b/mercurial/strutil.py	Fri Oct 10 11:32:38 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]]