##// END OF EJS Templates
py3: have a bytes version of shlex.split()...
Pulkit Goyal -
r30678:caf7e1c5 default
parent child Browse files
Show More
@@ -64,7 +64,6 b' from __future__ import absolute_import'
64 64
65 65 import os
66 66 import re
67 import shlex
68 67 import shutil
69 68 import tempfile
70 69 from mercurial.i18n import _
@@ -78,6 +77,7 b' from mercurial import ('
78 77 commands,
79 78 error,
80 79 filemerge,
80 pycompat,
81 81 scmutil,
82 82 util,
83 83 )
@@ -371,7 +371,7 b' def uisetup(ui):'
371 371 if path:
372 372 # case "cmd = path opts"
373 373 cmdline = path
374 diffopts = len(shlex.split(cmdline)) > 1
374 diffopts = len(pycompat.shlexsplit(cmdline)) > 1
375 375 else:
376 376 # case "cmd ="
377 377 path = util.findexe(cmd)
@@ -11,7 +11,6 b' import difflib'
11 11 import errno
12 12 import os
13 13 import re
14 import shlex
15 14 import socket
16 15 import string
17 16 import sys
@@ -1981,7 +1980,7 b' def debuginstall(ui, **opts):'
1981 1980 editor = ui.geteditor()
1982 1981 editor = util.expandpath(editor)
1983 1982 fm.write('editor', _("checking commit editor... (%s)\n"), editor)
1984 cmdpath = util.findexe(shlex.split(editor)[0])
1983 cmdpath = util.findexe(pycompat.shlexsplit(editor)[0])
1985 1984 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1986 1985 _(" No commit editor set and can't find %s in PATH\n"
1987 1986 " (specify a commit editor in your configuration"
@@ -14,7 +14,6 b' import getopt'
14 14 import os
15 15 import pdb
16 16 import re
17 import shlex
18 17 import signal
19 18 import sys
20 19 import time
@@ -279,7 +278,7 b' def aliasargs(fn, givenargs):'
279 278 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
280 279 givenargs = [x for i, x in enumerate(givenargs)
281 280 if i not in nums]
282 args = shlex.split(cmd)
281 args = pycompat.shlexsplit(cmd)
283 282 return args + givenargs
284 283
285 284 def aliasinterpolate(name, args, cmd):
@@ -351,7 +350,7 b' class cmdalias(object):'
351 350 return
352 351
353 352 try:
354 args = shlex.split(self.definition)
353 args = pycompat.shlexsplit(self.definition)
355 354 except ValueError as inst:
356 355 self.badalias = (_("error in definition for alias '%s': %s")
357 356 % (self.name, inst))
@@ -461,7 +460,7 b' def _parse(ui, args):'
461 460 args = aliasargs(entry[0], args)
462 461 defaults = ui.config("defaults", cmd)
463 462 if defaults:
464 args = map(util.expandpath, shlex.split(defaults)) + args
463 args = map(util.expandpath, pycompat.shlexsplit(defaults)) + args
465 464 c = list(entry[1])
466 465 else:
467 466 cmd = None
@@ -12,6 +12,7 b' from __future__ import absolute_import'
12 12
13 13 import getopt
14 14 import os
15 import shlex
15 16 import sys
16 17
17 18 ispy3 = (sys.version_info[0] >= 3)
@@ -122,6 +123,14 b' if ispy3:'
122 123 dic = dict((k.encode('latin-1'), v) for k, v in dic.iteritems())
123 124 return dic
124 125
126 # shlex.split() accepts unicodes on Python 3. This function takes bytes
127 # argument, convert it into unicodes, pass into shlex.split(), convert the
128 # returned value to bytes and return that.
129 # TODO: handle shlex.shlex().
130 def shlexsplit(s):
131 ret = shlex.split(s.decode('latin-1'))
132 return [a.encode('latin-1') for a in ret]
133
125 134 else:
126 135 def sysstr(s):
127 136 return s
@@ -162,6 +171,7 b' else:'
162 171 getcwd = os.getcwd
163 172 osgetenv = os.getenv
164 173 sysexecutable = sys.executable
174 shlexsplit = shlex.split
165 175
166 176 stringio = io.StringIO
167 177 empty = _queue.Empty
General Comments 0
You need to be logged in to leave comments. Login now