[PATCH] splicemap: support for path with spaces in splicemap (issue3844)

Szymon Wróblewski bluex0 at gmail.com
Mon Apr 29 18:09:18 CDT 2013


This should be enough, if behavior depending on os is acceptable.

# HG changeset patch
# User Szymon Wroblewski <bluex0 at gmail.com>
# Date 1367276230 -7200
# Branch stable
# Node ID 1291d5db2a88fe4b42817802385d5c462a86876b
# Parent  f01a351db79106ba96ac6d527cf69944fd98e665
splicemap: support paths with spaces in splicemap (issue3844)

Shlex module was used to split line as suggested. Split behavior depends on
os
(to support backslash in path on windows).

diff -r f01a351db791 -r 1291d5db2a88 hgext/convert/common.py
--- a/hgext/convert/common.py Fri Apr 26 01:12:03 2013 +0900
+++ b/hgext/convert/common.py Tue Apr 30 00:57:10 2013 +0200
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.

-import base64, errno, subprocess, os, datetime
+import base64, errno, subprocess, os, datetime, shlex
 import cPickle as pickle
 from mercurial import util
 from mercurial.i18n import _
@@ -437,9 +437,10 @@
                 # Ignore blank lines
                 continue
             try:
-                child, parents = line.split(' ', 1)
-                parents = parents.replace(',', ' ').split()
-            except ValueError:
+                line = shlex.split(line.replace(',', ' '),
+                                   posix=(os.name != 'nt'))
+                child, parents = line[0], line[1:]
+            except IndexError:
                 raise util.Abort(_('syntax error in %s(%d): child parent1'
                                    '[,parent2] expected') % (path, i + 1))
             pp = []



2013/4/29 Kevin Bullock <kbullock+mercurial at ringworld.org>

> On 29 Apr 2013, at 1:46 PM, Szymon Wróblewski wrote:
>
> > # HG changeset patch
> > # User Szymon Wroblewski <bluex0 at gmail.com>
> > # Date 1367260981 -7200
> > # Branch stable
> > # Node ID 79f31e640403180f928edf5d183e6dd7e62878b5
> > # Parent  f01a351db79106ba96ac6d527cf69944fd98e665
> > splicemap: support for path with spaces in splicemap (issue3844)
> >
> > Probably the easiest way to support path with spaces, without need to
> use any
> > kind of escaping or encoding. This way however makes syntax strictly
> consistent
> > with documentation (previously it was possible to use whitespaces as path
> > separators).
> >
> > diff -r f01a351db791 -r 79f31e640403 hgext/convert/common.py
> > --- a/hgext/convert/common.py Fri Apr 26 01:12:03 2013 +0900
> > +++ b/hgext/convert/common.py Mon Apr 29 20:43:01 2013 +0200
> > @@ -438,12 +438,13 @@
> >                 continue
> >             try:
> >                 child, parents = line.split(' ', 1)
> > -                parents = parents.replace(',', ' ').split()
> > +                parents = parents.split(',')
>
> As I understand it, we have to support spaces in _all three_ fields in a
> splicemap (child, parent1, parent2). Your patch doesn't fix the bug for the
> 'child' field.
>
> Look into using the shlex module, as suggested in <
> http://bz.selenic.com/show_bug.cgi?id=3844#c1>.
>
> pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
> Kevin R. Bullock
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130430/1e860977/attachment.html>


More information about the Mercurial-devel mailing list