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