Patchwork splicemap: support for path with spaces in splicemap (issue3844)

login
register
mail settings
Submitter Szymon Wróblewski
Date April 29, 2013, 11:09 p.m.
Message ID <CAF-_pHinUvh8MGUKHd8ZFWrWHkfQd+X1yrhrQP8JXTZGWdR=Vg@mail.gmail.com>
Download mbox | patch
Permalink /patch/1504/
State Changes Requested
Headers show

Comments

Matt Mackall - April 30, 2013, 8:18 p.m.
On Tue, 2013-04-30 at 01:09 +0200, Szymon Wróblewski wrote:
> This should be enough, if behavior depending on os is acceptable.
> 
> # HG changeset patch
> # User Szymon Wroblewski <bluex0@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).

So here's what that posix switch does:

http://docs.python.org/2.7/library/shlex.html#parsing-rules

In short.. it's completely different. Having the parsing rules be
completely different is suboptimal. We might want to instead have posix
mode always off.

This wants some test cases added to the existing splicemap test.

Patch

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 = []