Show More
@@ -8,11 +8,13 b' import sys' | |||||
8 | from mercurial import ( |
|
8 | from mercurial import ( | |
9 | node, |
|
9 | node, | |
10 | revlog, |
|
10 | revlog, | |
11 | util, |
|
11 | ) | |
|
12 | from mercurial.utils import ( | |||
|
13 | procutil, | |||
12 | ) |
|
14 | ) | |
13 |
|
15 | |||
14 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
16 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
15 | util.setbinary(fp) |
|
17 | procutil.setbinary(fp) | |
16 |
|
18 | |||
17 | def binopen(path, mode='rb'): |
|
19 | def binopen(path, mode='rb'): | |
18 | if 'b' not in mode: |
|
20 | if 'b' not in mode: |
@@ -66,6 +66,9 b' from mercurial import (' | |||||
66 | url as urlmod, |
|
66 | url as urlmod, | |
67 | util, |
|
67 | util, | |
68 | ) |
|
68 | ) | |
|
69 | from mercurial.utils import ( | |||
|
70 | procutil, | |||
|
71 | ) | |||
69 |
|
72 | |||
70 | cmdtable = {} |
|
73 | cmdtable = {} | |
71 | command = registrar.command(cmdtable) |
|
74 | command = registrar.command(cmdtable) | |
@@ -161,7 +164,8 b' def callconduit(repo, name, params):' | |||||
161 | data = urlencodenested(params) |
|
164 | data = urlencodenested(params) | |
162 | curlcmd = repo.ui.config('phabricator', 'curlcmd') |
|
165 | curlcmd = repo.ui.config('phabricator', 'curlcmd') | |
163 | if curlcmd: |
|
166 | if curlcmd: | |
164 |
sin, sout = util.popen2('%s -d @- %s' |
|
167 | sin, sout = procutil.popen2('%s -d @- %s' | |
|
168 | % (curlcmd, procutil.shellquote(url))) | |||
165 | sin.write(data) |
|
169 | sin.write(data) | |
166 | sin.close() |
|
170 | sin.close() | |
167 | body = sout.read() |
|
171 | body = sout.read() |
@@ -14,7 +14,9 b' from mercurial import (' | |||||
14 | fancyopts, |
|
14 | fancyopts, | |
15 | simplemerge, |
|
15 | simplemerge, | |
16 | ui as uimod, |
|
16 | ui as uimod, | |
17 | util, |
|
17 | ) | |
|
18 | from mercurial.utils import ( | |||
|
19 | procutil, | |||
18 | ) |
|
20 | ) | |
19 |
|
21 | |||
20 | options = [('L', 'label', [], _('labels to use on conflict markers')), |
|
22 | options = [('L', 'label', [], _('labels to use on conflict markers')), | |
@@ -52,7 +54,7 b' def showhelp():' | |||||
52 |
|
54 | |||
53 | try: |
|
55 | try: | |
54 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
56 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
55 | util.setbinary(fp) |
|
57 | procutil.setbinary(fp) | |
56 |
|
58 | |||
57 | opts = {} |
|
59 | opts = {} | |
58 | try: |
|
60 | try: |
@@ -10,12 +10,14 b' from mercurial import (' | |||||
10 | node, |
|
10 | node, | |
11 | revlog, |
|
11 | revlog, | |
12 | transaction, |
|
12 | transaction, | |
13 | util, |
|
|||
14 | vfs as vfsmod, |
|
13 | vfs as vfsmod, | |
15 | ) |
|
14 | ) | |
|
15 | from mercurial.utils import ( | |||
|
16 | procutil, | |||
|
17 | ) | |||
16 |
|
18 | |||
17 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
19 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
18 | util.setbinary(fp) |
|
20 | procutil.setbinary(fp) | |
19 |
|
21 | |||
20 | opener = vfsmod.vfs('.', False) |
|
22 | opener = vfsmod.vfs('.', False) | |
21 | tr = transaction.transaction(sys.stderr.write, opener, {'store': opener}, |
|
23 | tr = transaction.transaction(sys.stderr.write, opener, {'store': opener}, |
@@ -201,6 +201,9 b' from mercurial import (' | |||||
201 | registrar, |
|
201 | registrar, | |
202 | util, |
|
202 | util, | |
203 | ) |
|
203 | ) | |
|
204 | from mercurial.utils import ( | |||
|
205 | procutil, | |||
|
206 | ) | |||
204 |
|
207 | |||
205 | urlreq = util.urlreq |
|
208 | urlreq = util.urlreq | |
206 |
|
209 | |||
@@ -338,7 +341,7 b' def hook(ui, repo, hooktype, node=None, ' | |||||
338 | user = urlreq.unquote(url[3]) |
|
341 | user = urlreq.unquote(url[3]) | |
339 |
|
342 | |||
340 | if user is None: |
|
343 | if user is None: | |
341 | user = util.getuser() |
|
344 | user = procutil.getuser() | |
342 |
|
345 | |||
343 | ui.debug('acl: checking access for user "%s"\n' % user) |
|
346 | ui.debug('acl: checking access for user "%s"\n' % user) | |
344 |
|
347 |
@@ -49,7 +49,10 b' from mercurial import (' | |||||
49 | ui as uimod, |
|
49 | ui as uimod, | |
50 | util, |
|
50 | util, | |
51 | ) |
|
51 | ) | |
52 |
from mercurial.utils import |
|
52 | from mercurial.utils import ( | |
|
53 | dateutil, | |||
|
54 | procutil, | |||
|
55 | ) | |||
53 |
|
56 | |||
54 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
57 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
55 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
58 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
@@ -166,8 +169,8 b' def wrapui(ui):' | |||||
166 | ui._bbinlog = True |
|
169 | ui._bbinlog = True | |
167 | default = self.configdate('devel', 'default-date') |
|
170 | default = self.configdate('devel', 'default-date') | |
168 | date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S') |
|
171 | date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S') | |
169 | user = util.getuser() |
|
172 | user = procutil.getuser() | |
170 | pid = '%d' % util.getpid() |
|
173 | pid = '%d' % procutil.getpid() | |
171 | formattedmsg = msg[0] % msg[1:] |
|
174 | formattedmsg = msg[0] % msg[1:] | |
172 | rev = '(unknown)' |
|
175 | rev = '(unknown)' | |
173 | changed = '' |
|
176 | changed = '' |
@@ -308,6 +308,7 b' from mercurial import (' | |||||
308 | util, |
|
308 | util, | |
309 | ) |
|
309 | ) | |
310 | from mercurial.utils import ( |
|
310 | from mercurial.utils import ( | |
|
311 | procutil, | |||
311 | stringutil, |
|
312 | stringutil, | |
312 | ) |
|
313 | ) | |
313 |
|
314 | |||
@@ -527,13 +528,13 b' class bzmysql(bzaccess):' | |||||
527 | except TypeError: |
|
528 | except TypeError: | |
528 | cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user} |
|
529 | cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user} | |
529 | self.ui.note(_('running notify command %s\n') % cmd) |
|
530 | self.ui.note(_('running notify command %s\n') % cmd) | |
530 | fp = util.popen('(%s) 2>&1' % cmd) |
|
531 | fp = procutil.popen('(%s) 2>&1' % cmd) | |
531 | out = fp.read() |
|
532 | out = fp.read() | |
532 | ret = fp.close() |
|
533 | ret = fp.close() | |
533 | if ret: |
|
534 | if ret: | |
534 | self.ui.warn(out) |
|
535 | self.ui.warn(out) | |
535 | raise error.Abort(_('bugzilla notify command %s') % |
|
536 | raise error.Abort(_('bugzilla notify command %s') % | |
536 | util.explainexit(ret)[0]) |
|
537 | procutil.explainexit(ret)[0]) | |
537 | self.ui.status(_('done\n')) |
|
538 | self.ui.status(_('done\n')) | |
538 |
|
539 | |||
539 | def get_user_id(self, user): |
|
540 | def get_user_id(self, user): |
@@ -22,6 +22,9 b' from mercurial import (' | |||||
22 | pycompat, |
|
22 | pycompat, | |
23 | util, |
|
23 | util, | |
24 | ) |
|
24 | ) | |
|
25 | from mercurial.utils import ( | |||
|
26 | procutil, | |||
|
27 | ) | |||
25 |
|
28 | |||
26 | pickle = util.pickle |
|
29 | pickle = util.pickle | |
27 | propertycache = util.propertycache |
|
30 | propertycache = util.propertycache | |
@@ -96,7 +99,7 b' class MissingTool(Exception):' | |||||
96 |
|
99 | |||
97 | def checktool(exe, name=None, abort=True): |
|
100 | def checktool(exe, name=None, abort=True): | |
98 | name = name or exe |
|
101 | name = name or exe | |
99 | if not util.findexe(exe): |
|
102 | if not procutil.findexe(exe): | |
100 | if abort: |
|
103 | if abort: | |
101 | exc = error.Abort |
|
104 | exc = error.Abort | |
102 | else: |
|
105 | else: | |
@@ -390,7 +393,7 b' class commandline(object):' | |||||
390 | cmdline[-1] += '=' + v |
|
393 | cmdline[-1] += '=' + v | |
391 | except TypeError: |
|
394 | except TypeError: | |
392 | pass |
|
395 | pass | |
393 | cmdline = [util.shellquote(arg) for arg in cmdline] |
|
396 | cmdline = [procutil.shellquote(arg) for arg in cmdline] | |
394 | if not self.ui.debugflag: |
|
397 | if not self.ui.debugflag: | |
395 | cmdline += ['2>', pycompat.bytestr(os.devnull)] |
|
398 | cmdline += ['2>', pycompat.bytestr(os.devnull)] | |
396 | cmdline = ' '.join(cmdline) |
|
399 | cmdline = ' '.join(cmdline) | |
@@ -399,16 +402,16 b' class commandline(object):' | |||||
399 | def _run(self, cmd, *args, **kwargs): |
|
402 | def _run(self, cmd, *args, **kwargs): | |
400 | def popen(cmdline): |
|
403 | def popen(cmdline): | |
401 | p = subprocess.Popen(cmdline, shell=True, bufsize=-1, |
|
404 | p = subprocess.Popen(cmdline, shell=True, bufsize=-1, | |
402 | close_fds=util.closefds, |
|
405 | close_fds=procutil.closefds, | |
403 | stdout=subprocess.PIPE) |
|
406 | stdout=subprocess.PIPE) | |
404 | return p |
|
407 | return p | |
405 | return self._dorun(popen, cmd, *args, **kwargs) |
|
408 | return self._dorun(popen, cmd, *args, **kwargs) | |
406 |
|
409 | |||
407 | def _run2(self, cmd, *args, **kwargs): |
|
410 | def _run2(self, cmd, *args, **kwargs): | |
408 | return self._dorun(util.popen2, cmd, *args, **kwargs) |
|
411 | return self._dorun(procutil.popen2, cmd, *args, **kwargs) | |
409 |
|
412 | |||
410 | def _run3(self, cmd, *args, **kwargs): |
|
413 | def _run3(self, cmd, *args, **kwargs): | |
411 | return self._dorun(util.popen3, cmd, *args, **kwargs) |
|
414 | return self._dorun(procutil.popen3, cmd, *args, **kwargs) | |
412 |
|
415 | |||
413 | def _dorun(self, openfunc, cmd, *args, **kwargs): |
|
416 | def _dorun(self, openfunc, cmd, *args, **kwargs): | |
414 | cmdline = self._cmdline(cmd, *args, **kwargs) |
|
417 | cmdline = self._cmdline(cmd, *args, **kwargs) | |
@@ -437,7 +440,7 b' class commandline(object):' | |||||
437 | if output: |
|
440 | if output: | |
438 | self.ui.warn(_('%s error:\n') % self.command) |
|
441 | self.ui.warn(_('%s error:\n') % self.command) | |
439 | self.ui.warn(output) |
|
442 | self.ui.warn(output) | |
440 | msg = util.explainexit(status)[0] |
|
443 | msg = procutil.explainexit(status)[0] | |
441 | raise error.Abort('%s %s' % (self.command, msg)) |
|
444 | raise error.Abort('%s %s' % (self.command, msg)) | |
442 |
|
445 | |||
443 | def run0(self, cmd, *args, **kwargs): |
|
446 | def run0(self, cmd, *args, **kwargs): |
@@ -18,7 +18,10 b' from mercurial import (' | |||||
18 | pycompat, |
|
18 | pycompat, | |
19 | util, |
|
19 | util, | |
20 | ) |
|
20 | ) | |
21 |
from mercurial.utils import |
|
21 | from mercurial.utils import ( | |
|
22 | dateutil, | |||
|
23 | procutil, | |||
|
24 | ) | |||
22 |
|
25 | |||
23 | from . import ( |
|
26 | from . import ( | |
24 | common, |
|
27 | common, | |
@@ -197,9 +200,9 b' class convert_cvs(converter_source):' | |||||
197 | cmd = [rsh, host] + cmd |
|
200 | cmd = [rsh, host] + cmd | |
198 |
|
201 | |||
199 | # popen2 does not support argument lists under Windows |
|
202 | # popen2 does not support argument lists under Windows | |
200 | cmd = [util.shellquote(arg) for arg in cmd] |
|
203 | cmd = [procutil.shellquote(arg) for arg in cmd] | |
201 | cmd = util.quotecommand(' '.join(cmd)) |
|
204 | cmd = procutil.quotecommand(' '.join(cmd)) | |
202 | self.writep, self.readp = util.popen2(cmd) |
|
205 | self.writep, self.readp = procutil.popen2(cmd) | |
203 |
|
206 | |||
204 | self.realroot = root |
|
207 | self.realroot = root | |
205 |
|
208 |
@@ -19,6 +19,7 b' from mercurial import (' | |||||
19 | ) |
|
19 | ) | |
20 | from mercurial.utils import ( |
|
20 | from mercurial.utils import ( | |
21 | dateutil, |
|
21 | dateutil, | |
|
22 | procutil, | |||
22 | stringutil, |
|
23 | stringutil, | |
23 | ) |
|
24 | ) | |
24 |
|
25 | |||
@@ -223,11 +224,11 b' def createlog(ui, directory=None, root="' | |||||
223 | state = 0 |
|
224 | state = 0 | |
224 | store = False # set when a new record can be appended |
|
225 | store = False # set when a new record can be appended | |
225 |
|
226 | |||
226 | cmd = [util.shellquote(arg) for arg in cmd] |
|
227 | cmd = [procutil.shellquote(arg) for arg in cmd] | |
227 | ui.note(_("running %s\n") % (' '.join(cmd))) |
|
228 | ui.note(_("running %s\n") % (' '.join(cmd))) | |
228 | ui.debug("prefix=%r directory=%r root=%r\n" % (prefix, directory, root)) |
|
229 | ui.debug("prefix=%r directory=%r root=%r\n" % (prefix, directory, root)) | |
229 |
|
230 | |||
230 | pfp = util.popen(' '.join(cmd)) |
|
231 | pfp = procutil.popen(' '.join(cmd)) | |
231 | peek = pfp.readline() |
|
232 | peek = pfp.readline() | |
232 | while True: |
|
233 | while True: | |
233 | line = peek |
|
234 | line = peek |
@@ -17,9 +17,11 b' from mercurial.i18n import _' | |||||
17 | from mercurial import ( |
|
17 | from mercurial import ( | |
18 | encoding, |
|
18 | encoding, | |
19 | error, |
|
19 | error, | |
20 | util, |
|
|||
21 | ) |
|
20 | ) | |
22 |
from mercurial.utils import |
|
21 | from mercurial.utils import ( | |
|
22 | dateutil, | |||
|
23 | procutil, | |||
|
24 | ) | |||
23 | from . import common |
|
25 | from . import common | |
24 |
|
26 | |||
25 | class gnuarch_source(common.converter_source, common.commandline): |
|
27 | class gnuarch_source(common.converter_source, common.commandline): | |
@@ -46,10 +48,10 b' class gnuarch_source(common.converter_so' | |||||
46 |
|
48 | |||
47 | # Could use checktool, but we want to check for baz or tla. |
|
49 | # Could use checktool, but we want to check for baz or tla. | |
48 | self.execmd = None |
|
50 | self.execmd = None | |
49 | if util.findexe('baz'): |
|
51 | if procutil.findexe('baz'): | |
50 | self.execmd = 'baz' |
|
52 | self.execmd = 'baz' | |
51 | else: |
|
53 | else: | |
52 | if util.findexe('tla'): |
|
54 | if procutil.findexe('tla'): | |
53 | self.execmd = 'tla' |
|
55 | self.execmd = 'tla' | |
54 | else: |
|
56 | else: | |
55 | raise error.Abort(_('cannot find a GNU Arch tool')) |
|
57 | raise error.Abort(_('cannot find a GNU Arch tool')) | |
@@ -195,9 +197,9 b' class gnuarch_source(common.converter_so' | |||||
195 | def _execute(self, cmd, *args, **kwargs): |
|
197 | def _execute(self, cmd, *args, **kwargs): | |
196 | cmdline = [self.execmd, cmd] |
|
198 | cmdline = [self.execmd, cmd] | |
197 | cmdline += args |
|
199 | cmdline += args | |
198 | cmdline = [util.shellquote(arg) for arg in cmdline] |
|
200 | cmdline = [procutil.shellquote(arg) for arg in cmdline] | |
199 | cmdline += ['>', os.devnull, '2>', os.devnull] |
|
201 | cmdline += ['>', os.devnull, '2>', os.devnull] | |
200 | cmdline = util.quotecommand(' '.join(cmdline)) |
|
202 | cmdline = procutil.quotecommand(' '.join(cmdline)) | |
201 | self.ui.debug(cmdline, '\n') |
|
203 | self.ui.debug(cmdline, '\n') | |
202 | return os.system(cmdline) |
|
204 | return os.system(cmdline) | |
203 |
|
205 |
@@ -16,6 +16,7 b' from mercurial import (' | |||||
16 | ) |
|
16 | ) | |
17 | from mercurial.utils import ( |
|
17 | from mercurial.utils import ( | |
18 | dateutil, |
|
18 | dateutil, | |
|
19 | procutil, | |||
19 | stringutil, |
|
20 | stringutil, | |
20 | ) |
|
21 | ) | |
21 |
|
22 | |||
@@ -89,8 +90,8 b' class p4_source(common.converter_source)' | |||||
89 |
|
90 | |||
90 | def _parse_view(self, path): |
|
91 | def _parse_view(self, path): | |
91 | "Read changes affecting the path" |
|
92 | "Read changes affecting the path" | |
92 | cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path) |
|
93 | cmd = 'p4 -G changes -s submitted %s' % procutil.shellquote(path) | |
93 | stdout = util.popen(cmd, mode='rb') |
|
94 | stdout = procutil.popen(cmd, mode='rb') | |
94 | p4changes = {} |
|
95 | p4changes = {} | |
95 | for d in loaditer(stdout): |
|
96 | for d in loaditer(stdout): | |
96 | c = d.get("change", None) |
|
97 | c = d.get("change", None) | |
@@ -118,8 +119,8 b' class p4_source(common.converter_source)' | |||||
118 | else: |
|
119 | else: | |
119 | views = {"//": ""} |
|
120 | views = {"//": ""} | |
120 | else: |
|
121 | else: | |
121 | cmd = 'p4 -G client -o %s' % util.shellquote(path) |
|
122 | cmd = 'p4 -G client -o %s' % procutil.shellquote(path) | |
122 | clientspec = marshal.load(util.popen(cmd, mode='rb')) |
|
123 | clientspec = marshal.load(procutil.popen(cmd, mode='rb')) | |
123 |
|
124 | |||
124 | views = {} |
|
125 | views = {} | |
125 | for client in clientspec: |
|
126 | for client in clientspec: | |
@@ -198,8 +199,8 b' class p4_source(common.converter_source)' | |||||
198 | oldname = depotname[filename] |
|
199 | oldname = depotname[filename] | |
199 |
|
200 | |||
200 | flcmd = 'p4 -G filelog %s' \ |
|
201 | flcmd = 'p4 -G filelog %s' \ | |
201 | % util.shellquote(oldname) |
|
202 | % procutil.shellquote(oldname) | |
202 | flstdout = util.popen(flcmd, mode='rb') |
|
203 | flstdout = procutil.popen(flcmd, mode='rb') | |
203 |
|
204 | |||
204 | copiedfilename = None |
|
205 | copiedfilename = None | |
205 | for d in loaditer(flstdout): |
|
206 | for d in loaditer(flstdout): | |
@@ -272,11 +273,11 b' class p4_source(common.converter_source)' | |||||
272 |
|
273 | |||
273 | def getfile(self, name, rev): |
|
274 | def getfile(self, name, rev): | |
274 | cmd = 'p4 -G print %s' \ |
|
275 | cmd = 'p4 -G print %s' \ | |
275 | % util.shellquote("%s#%s" % (self.depotname[name], rev)) |
|
276 | % procutil.shellquote("%s#%s" % (self.depotname[name], rev)) | |
276 |
|
277 | |||
277 | lasterror = None |
|
278 | lasterror = None | |
278 | while True: |
|
279 | while True: | |
279 | stdout = util.popen(cmd, mode='rb') |
|
280 | stdout = procutil.popen(cmd, mode='rb') | |
280 |
|
281 | |||
281 | mode = None |
|
282 | mode = None | |
282 | contents = [] |
|
283 | contents = [] | |
@@ -358,7 +359,7 b' class p4_source(common.converter_source)' | |||||
358 | """Return an output of `p4 describe` including author, commit date as |
|
359 | """Return an output of `p4 describe` including author, commit date as | |
359 | a dictionary.""" |
|
360 | a dictionary.""" | |
360 | cmd = "p4 -G describe -s %s" % rev |
|
361 | cmd = "p4 -G describe -s %s" % rev | |
361 | stdout = util.popen(cmd, mode='rb') |
|
362 | stdout = procutil.popen(cmd, mode='rb') | |
362 | return marshal.load(stdout) |
|
363 | return marshal.load(stdout) | |
363 |
|
364 | |||
364 | def getcommit(self, rev): |
|
365 | def getcommit(self, rev): |
@@ -18,6 +18,7 b' from mercurial import (' | |||||
18 | ) |
|
18 | ) | |
19 | from mercurial.utils import ( |
|
19 | from mercurial.utils import ( | |
20 | dateutil, |
|
20 | dateutil, | |
|
21 | procutil, | |||
21 | stringutil, |
|
22 | stringutil, | |
22 | ) |
|
23 | ) | |
23 |
|
24 | |||
@@ -1069,9 +1070,9 b' class svn_source(converter_source):' | |||||
1069 | if not self.ui.configbool('convert', 'svn.debugsvnlog'): |
|
1070 | if not self.ui.configbool('convert', 'svn.debugsvnlog'): | |
1070 | return directlogstream(*args) |
|
1071 | return directlogstream(*args) | |
1071 | arg = encodeargs(args) |
|
1072 | arg = encodeargs(args) | |
1072 | hgexe = util.hgexecutable() |
|
1073 | hgexe = procutil.hgexecutable() | |
1073 | cmd = '%s debugsvnlog' % util.shellquote(hgexe) |
|
1074 | cmd = '%s debugsvnlog' % procutil.shellquote(hgexe) | |
1074 | stdin, stdout = util.popen2(util.quotecommand(cmd)) |
|
1075 | stdin, stdout = procutil.popen2(procutil.quotecommand(cmd)) | |
1075 | stdin.write(arg) |
|
1076 | stdin.write(arg) | |
1076 | try: |
|
1077 | try: | |
1077 | stdin.close() |
|
1078 | stdin.close() |
@@ -83,6 +83,7 b' from mercurial import (' | |||||
83 | util, |
|
83 | util, | |
84 | ) |
|
84 | ) | |
85 | from mercurial.utils import ( |
|
85 | from mercurial.utils import ( | |
|
86 | procutil, | |||
86 | stringutil, |
|
87 | stringutil, | |
87 | ) |
|
88 | ) | |
88 |
|
89 | |||
@@ -280,7 +281,7 b' def dodiff(ui, repo, cmdline, pats, opts' | |||||
280 | key = match.group(3) |
|
281 | key = match.group(3) | |
281 | if not do3way and key == 'parent2': |
|
282 | if not do3way and key == 'parent2': | |
282 | return pre |
|
283 | return pre | |
283 | return pre + util.shellquote(replace[key]) |
|
284 | return pre + procutil.shellquote(replace[key]) | |
284 |
|
285 | |||
285 | # Match parent2 first, so 'parent1?' will match both parent1 and parent |
|
286 | # Match parent2 first, so 'parent1?' will match both parent1 and parent | |
286 | regex = (br'''(['"]?)([^\s'"$]*)''' |
|
287 | regex = (br'''(['"]?)([^\s'"$]*)''' | |
@@ -349,7 +350,7 b' def extdiff(ui, repo, *pats, **opts):' | |||||
349 | if not program: |
|
350 | if not program: | |
350 | program = 'diff' |
|
351 | program = 'diff' | |
351 | option = option or ['-Npru'] |
|
352 | option = option or ['-Npru'] | |
352 | cmdline = ' '.join(map(util.shellquote, [program] + option)) |
|
353 | cmdline = ' '.join(map(procutil.shellquote, [program] + option)) | |
353 | return dodiff(ui, repo, cmdline, pats, opts) |
|
354 | return dodiff(ui, repo, cmdline, pats, opts) | |
354 |
|
355 | |||
355 | class savedcmd(object): |
|
356 | class savedcmd(object): | |
@@ -376,7 +377,7 b' class savedcmd(object):' | |||||
376 |
|
377 | |||
377 | def __call__(self, ui, repo, *pats, **opts): |
|
378 | def __call__(self, ui, repo, *pats, **opts): | |
378 | opts = pycompat.byteskwargs(opts) |
|
379 | opts = pycompat.byteskwargs(opts) | |
379 | options = ' '.join(map(util.shellquote, opts['option'])) |
|
380 | options = ' '.join(map(procutil.shellquote, opts['option'])) | |
380 | if options: |
|
381 | if options: | |
381 | options = ' ' + options |
|
382 | options = ' ' + options | |
382 | return dodiff(ui, repo, self._cmdline + options, pats, opts) |
|
383 | return dodiff(ui, repo, self._cmdline + options, pats, opts) | |
@@ -387,11 +388,11 b' def uisetup(ui):' | |||||
387 | if cmd.startswith('cmd.'): |
|
388 | if cmd.startswith('cmd.'): | |
388 | cmd = cmd[4:] |
|
389 | cmd = cmd[4:] | |
389 | if not path: |
|
390 | if not path: | |
390 | path = util.findexe(cmd) |
|
391 | path = procutil.findexe(cmd) | |
391 | if path is None: |
|
392 | if path is None: | |
392 | path = filemerge.findexternaltool(ui, cmd) or cmd |
|
393 | path = filemerge.findexternaltool(ui, cmd) or cmd | |
393 | diffopts = ui.config('extdiff', 'opts.' + cmd) |
|
394 | diffopts = ui.config('extdiff', 'opts.' + cmd) | |
394 | cmdline = util.shellquote(path) |
|
395 | cmdline = procutil.shellquote(path) | |
395 | if diffopts: |
|
396 | if diffopts: | |
396 | cmdline += ' ' + diffopts |
|
397 | cmdline += ' ' + diffopts | |
397 | elif cmd.startswith('opts.'): |
|
398 | elif cmd.startswith('opts.'): | |
@@ -403,10 +404,10 b' def uisetup(ui):' | |||||
403 | diffopts = len(pycompat.shlexsplit(cmdline)) > 1 |
|
404 | diffopts = len(pycompat.shlexsplit(cmdline)) > 1 | |
404 | else: |
|
405 | else: | |
405 | # case "cmd =" |
|
406 | # case "cmd =" | |
406 | path = util.findexe(cmd) |
|
407 | path = procutil.findexe(cmd) | |
407 | if path is None: |
|
408 | if path is None: | |
408 | path = filemerge.findexternaltool(ui, cmd) or cmd |
|
409 | path = filemerge.findexternaltool(ui, cmd) or cmd | |
409 | cmdline = util.shellquote(path) |
|
410 | cmdline = procutil.shellquote(path) | |
410 | diffopts = False |
|
411 | diffopts = False | |
411 | # look for diff arguments in [diff-tools] then [merge-tools] |
|
412 | # look for diff arguments in [diff-tools] then [merge-tools] | |
412 | if not diffopts: |
|
413 | if not diffopts: |
@@ -26,7 +26,9 b' from mercurial import (' | |||||
26 | error, |
|
26 | error, | |
27 | fancyopts, |
|
27 | fancyopts, | |
28 | registrar, |
|
28 | registrar, | |
29 | util, |
|
29 | ) | |
|
30 | from mercurial.utils import ( | |||
|
31 | procutil, | |||
30 | ) |
|
32 | ) | |
31 |
|
33 | |||
32 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
34 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
@@ -625,7 +627,7 b' def lsfiles(ui, repo, *args, **kwargs):' | |||||
625 | cmd['-0'] = None |
|
627 | cmd['-0'] = None | |
626 | cmd.append('.') |
|
628 | cmd.append('.') | |
627 | for include in args: |
|
629 | for include in args: | |
628 | cmd['-I'] = util.shellquote(include) |
|
630 | cmd['-I'] = procutil.shellquote(include) | |
629 |
|
631 | |||
630 | ui.status((bytes(cmd)), "\n") |
|
632 | ui.status((bytes(cmd)), "\n") | |
631 |
|
633 |
@@ -19,9 +19,11 b' from mercurial import (' | |||||
19 | node as hgnode, |
|
19 | node as hgnode, | |
20 | pycompat, |
|
20 | pycompat, | |
21 | registrar, |
|
21 | registrar, | |
22 | util, |
|
|||
23 | ) |
|
22 | ) | |
24 |
from mercurial.utils import |
|
23 | from mercurial.utils import ( | |
|
24 | dateutil, | |||
|
25 | procutil, | |||
|
26 | ) | |||
25 |
|
27 | |||
26 | cmdtable = {} |
|
28 | cmdtable = {} | |
27 | command = registrar.command(cmdtable) |
|
29 | command = registrar.command(cmdtable) | |
@@ -52,7 +54,7 b' class gpg(object):' | |||||
52 |
|
54 | |||
53 | def sign(self, data): |
|
55 | def sign(self, data): | |
54 | gpgcmd = "%s --sign --detach-sign%s" % (self.path, self.key) |
|
56 | gpgcmd = "%s --sign --detach-sign%s" % (self.path, self.key) | |
55 | return util.filter(data, gpgcmd) |
|
57 | return procutil.filter(data, gpgcmd) | |
56 |
|
58 | |||
57 | def verify(self, data, sig): |
|
59 | def verify(self, data, sig): | |
58 | """ returns of the good and bad signatures""" |
|
60 | """ returns of the good and bad signatures""" | |
@@ -69,7 +71,7 b' class gpg(object):' | |||||
69 | fp.close() |
|
71 | fp.close() | |
70 | gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify " |
|
72 | gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify " | |
71 | "\"%s\" \"%s\"" % (self.path, sigfile, datafile)) |
|
73 | "\"%s\" \"%s\"" % (self.path, sigfile, datafile)) | |
72 | ret = util.filter("", gpgcmd) |
|
74 | ret = procutil.filter("", gpgcmd) | |
73 | finally: |
|
75 | finally: | |
74 | for f in (sigfile, datafile): |
|
76 | for f in (sigfile, datafile): | |
75 | try: |
|
77 | try: |
@@ -38,6 +38,7 b' from mercurial import (' | |||||
38 | ) |
|
38 | ) | |
39 | from mercurial.utils import ( |
|
39 | from mercurial.utils import ( | |
40 | dateutil, |
|
40 | dateutil, | |
|
41 | procutil, | |||
41 | stringutil, |
|
42 | stringutil, | |
42 | ) |
|
43 | ) | |
43 |
|
44 | |||
@@ -255,7 +256,7 b' class journalstorage(object):' | |||||
255 | _lockref = None |
|
256 | _lockref = None | |
256 |
|
257 | |||
257 | def __init__(self, repo): |
|
258 | def __init__(self, repo): | |
258 | self.user = util.getuser() |
|
259 | self.user = procutil.getuser() | |
259 | self.ui = repo.ui |
|
260 | self.ui = repo.ui | |
260 | self.vfs = repo.vfs |
|
261 | self.vfs = repo.vfs | |
261 |
|
262 | |||
@@ -272,7 +273,7 b' class journalstorage(object):' | |||||
272 | @property |
|
273 | @property | |
273 | def command(self): |
|
274 | def command(self): | |
274 | commandstr = ' '.join( |
|
275 | commandstr = ' '.join( | |
275 | map(util.shellquote, journalstorage._currentcommand)) |
|
276 | map(procutil.shellquote, journalstorage._currentcommand)) | |
276 | if '\n' in commandstr: |
|
277 | if '\n' in commandstr: | |
277 | # truncate multi-line commands |
|
278 | # truncate multi-line commands | |
278 | commandstr = commandstr.partition('\n')[0] + ' ...' |
|
279 | commandstr = commandstr.partition('\n')[0] + ' ...' |
@@ -39,6 +39,7 b' from mercurial import (' | |||||
39 | vfs as vfsmod, |
|
39 | vfs as vfsmod, | |
40 | ) |
|
40 | ) | |
41 | from mercurial.utils import ( |
|
41 | from mercurial.utils import ( | |
|
42 | procutil, | |||
42 | stringutil, |
|
43 | stringutil, | |
43 | ) |
|
44 | ) | |
44 |
|
45 | |||
@@ -271,8 +272,9 b' class transplanter(object):' | |||||
271 | fp.close() |
|
272 | fp.close() | |
272 |
|
273 | |||
273 | try: |
|
274 | try: | |
274 |
self.ui.system('%s %s %s' % (filter, |
|
275 | self.ui.system('%s %s %s' % (filter, | |
275 |
util.shellquote( |
|
276 | procutil.shellquote(headerfile), | |
|
277 | procutil.shellquote(patchfile)), | |||
276 | environ={'HGUSER': changelog[1], |
|
278 | environ={'HGUSER': changelog[1], | |
277 | 'HGREVISION': nodemod.hex(node), |
|
279 | 'HGREVISION': nodemod.hex(node), | |
278 | }, |
|
280 | }, |
@@ -205,12 +205,12 b' def _newchgui(srcui, csystem, attachio):' | |||||
205 | if (out is not self.fout |
|
205 | if (out is not self.fout | |
206 | or not util.safehasattr(self.fout, 'fileno') |
|
206 | or not util.safehasattr(self.fout, 'fileno') | |
207 | or self.fout.fileno() != procutil.stdout.fileno()): |
|
207 | or self.fout.fileno() != procutil.stdout.fileno()): | |
208 | return util.system(cmd, environ=environ, cwd=cwd, out=out) |
|
208 | return procutil.system(cmd, environ=environ, cwd=cwd, out=out) | |
209 | self.flush() |
|
209 | self.flush() | |
210 | return self._csystem(cmd, util.shellenviron(environ), cwd) |
|
210 | return self._csystem(cmd, procutil.shellenviron(environ), cwd) | |
211 |
|
211 | |||
212 | def _runpager(self, cmd, env=None): |
|
212 | def _runpager(self, cmd, env=None): | |
213 | self._csystem(cmd, util.shellenviron(env), type='pager', |
|
213 | self._csystem(cmd, procutil.shellenviron(env), type='pager', | |
214 | cmdtable={'attachio': attachio}) |
|
214 | cmdtable={'attachio': attachio}) | |
215 | return True |
|
215 | return True | |
216 |
|
216 | |||
@@ -271,7 +271,7 b' class channeledsystem(object):' | |||||
271 | self.channel = channel |
|
271 | self.channel = channel | |
272 |
|
272 | |||
273 | def __call__(self, cmd, environ, cwd=None, type='system', cmdtable=None): |
|
273 | def __call__(self, cmd, environ, cwd=None, type='system', cmdtable=None): | |
274 | args = [type, util.quotecommand(cmd), os.path.abspath(cwd or '.')] |
|
274 | args = [type, procutil.quotecommand(cmd), os.path.abspath(cwd or '.')] | |
275 | args.extend('%s=%s' % (k, v) for k, v in environ.iteritems()) |
|
275 | args.extend('%s=%s' % (k, v) for k, v in environ.iteritems()) | |
276 | data = '\0'.join(args) |
|
276 | data = '\0'.join(args) | |
277 | self.out.write(struct.pack('>cI', self.channel, len(data))) |
|
277 | self.out.write(struct.pack('>cI', self.channel, len(data))) | |
@@ -477,12 +477,12 b' class chgcmdserver(commandserver.server)' | |||||
477 | 'setenv': setenv, |
|
477 | 'setenv': setenv, | |
478 | 'setumask': setumask}) |
|
478 | 'setumask': setumask}) | |
479 |
|
479 | |||
480 | if util.safehasattr(util, 'setprocname'): |
|
480 | if util.safehasattr(procutil, 'setprocname'): | |
481 | def setprocname(self): |
|
481 | def setprocname(self): | |
482 | """Change process title""" |
|
482 | """Change process title""" | |
483 | name = self._readstr() |
|
483 | name = self._readstr() | |
484 | _log('setprocname: %r\n' % name) |
|
484 | _log('setprocname: %r\n' % name) | |
485 | util.setprocname(name) |
|
485 | procutil.setprocname(name) | |
486 | capabilities['setprocname'] = setprocname |
|
486 | capabilities['setprocname'] = setprocname | |
487 |
|
487 | |||
488 | def _tempaddress(address): |
|
488 | def _tempaddress(address): |
@@ -63,6 +63,7 b' from . import (' | |||||
63 | ) |
|
63 | ) | |
64 | from .utils import ( |
|
64 | from .utils import ( | |
65 | dateutil, |
|
65 | dateutil, | |
|
66 | procutil, | |||
66 | stringutil, |
|
67 | stringutil, | |
67 | ) |
|
68 | ) | |
68 |
|
69 | |||
@@ -2316,9 +2317,9 b' def _dograft(ui, repo, *revs, **opts):' | |||||
2316 | repo.vfs.write('graftstate', ''.join(nodelines)) |
|
2317 | repo.vfs.write('graftstate', ''.join(nodelines)) | |
2317 | extra = '' |
|
2318 | extra = '' | |
2318 | if opts.get('user'): |
|
2319 | if opts.get('user'): | |
2319 | extra += ' --user %s' % util.shellquote(opts['user']) |
|
2320 | extra += ' --user %s' % procutil.shellquote(opts['user']) | |
2320 | if opts.get('date'): |
|
2321 | if opts.get('date'): | |
2321 | extra += ' --date %s' % util.shellquote(opts['date']) |
|
2322 | extra += ' --date %s' % procutil.shellquote(opts['date']) | |
2322 | if opts.get('log'): |
|
2323 | if opts.get('log'): | |
2323 | extra += ' --log' |
|
2324 | extra += ' --log' | |
2324 | hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra |
|
2325 | hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra |
@@ -288,7 +288,7 b' class server(object):' | |||||
288 | hellomsg += '\n' |
|
288 | hellomsg += '\n' | |
289 | hellomsg += 'encoding: ' + encoding.encoding |
|
289 | hellomsg += 'encoding: ' + encoding.encoding | |
290 | hellomsg += '\n' |
|
290 | hellomsg += '\n' | |
291 | hellomsg += 'pid: %d' % util.getpid() |
|
291 | hellomsg += 'pid: %d' % procutil.getpid() | |
292 | if util.safehasattr(os, 'getpgid'): |
|
292 | if util.safehasattr(os, 'getpgid'): | |
293 | hellomsg += '\n' |
|
293 | hellomsg += '\n' | |
294 | hellomsg += 'pgid: %d' % os.getpgid(0) |
|
294 | hellomsg += 'pgid: %d' % os.getpgid(0) | |
@@ -457,8 +457,8 b' class unixforkingservice(object):' | |||||
457 | def init(self): |
|
457 | def init(self): | |
458 | self._sock = socket.socket(socket.AF_UNIX) |
|
458 | self._sock = socket.socket(socket.AF_UNIX) | |
459 | self._servicehandler.bindsocket(self._sock, self.address) |
|
459 | self._servicehandler.bindsocket(self._sock, self.address) | |
460 | if util.safehasattr(util, 'unblocksignal'): |
|
460 | if util.safehasattr(procutil, 'unblocksignal'): | |
461 | util.unblocksignal(signal.SIGCHLD) |
|
461 | procutil.unblocksignal(signal.SIGCHLD) | |
462 | o = signal.signal(signal.SIGCHLD, self._sigchldhandler) |
|
462 | o = signal.signal(signal.SIGCHLD, self._sigchldhandler) | |
463 | self._oldsigchldhandler = o |
|
463 | self._oldsigchldhandler = o | |
464 | self._socketunlinked = False |
|
464 | self._socketunlinked = False |
@@ -83,6 +83,7 b' from . import (' | |||||
83 | ) |
|
83 | ) | |
84 | from .utils import ( |
|
84 | from .utils import ( | |
85 | dateutil, |
|
85 | dateutil, | |
|
86 | procutil, | |||
86 | stringutil, |
|
87 | stringutil, | |
87 | ) |
|
88 | ) | |
88 |
|
89 | |||
@@ -1254,9 +1255,9 b' def debuginstall(ui, **opts):' | |||||
1254 | # editor |
|
1255 | # editor | |
1255 | editor = ui.geteditor() |
|
1256 | editor = ui.geteditor() | |
1256 | editor = util.expandpath(editor) |
|
1257 | editor = util.expandpath(editor) | |
1257 | editorbin = util.shellsplit(editor)[0] |
|
1258 | editorbin = procutil.shellsplit(editor)[0] | |
1258 | fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) |
|
1259 | fm.write('editor', _("checking commit editor... (%s)\n"), editorbin) | |
1259 | cmdpath = util.findexe(editorbin) |
|
1260 | cmdpath = procutil.findexe(editorbin) | |
1260 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
|
1261 | fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', | |
1261 | _(" No commit editor set and can't find %s in PATH\n" |
|
1262 | _(" No commit editor set and can't find %s in PATH\n" | |
1262 | " (specify a commit editor in your configuration" |
|
1263 | " (specify a commit editor in your configuration" | |
@@ -2813,7 +2814,7 b' def debugwireproto(ui, repo, path=None, ' | |||||
2813 | # We start the SSH server in its own process so there is process |
|
2814 | # We start the SSH server in its own process so there is process | |
2814 | # separation. This prevents a whole class of potential bugs around |
|
2815 | # separation. This prevents a whole class of potential bugs around | |
2815 | # shared state from interfering with server operation. |
|
2816 | # shared state from interfering with server operation. | |
2816 | args = util.hgcmd() + [ |
|
2817 | args = procutil.hgcmd() + [ | |
2817 | '-R', repo.root, |
|
2818 | '-R', repo.root, | |
2818 | 'debugserve', '--sshstdio', |
|
2819 | 'debugserve', '--sshstdio', | |
2819 | ] |
|
2820 | ] |
@@ -137,7 +137,7 b' if pycompat.ispy3:' | |||||
137 | else: |
|
137 | else: | |
138 | def _initstdio(): |
|
138 | def _initstdio(): | |
139 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
139 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
140 | util.setbinary(fp) |
|
140 | procutil.setbinary(fp) | |
141 |
|
141 | |||
142 | def _silencestdio(): |
|
142 | def _silencestdio(): | |
143 | pass |
|
143 | pass | |
@@ -172,7 +172,7 b' def _formatparse(write, inst):' | |||||
172 | write(_("(%s)\n") % inst.hint) |
|
172 | write(_("(%s)\n") % inst.hint) | |
173 |
|
173 | |||
174 | def _formatargs(args): |
|
174 | def _formatargs(args): | |
175 | return ' '.join(util.shellquote(a) for a in args) |
|
175 | return ' '.join(procutil.shellquote(a) for a in args) | |
176 |
|
176 | |||
177 | def dispatch(req): |
|
177 | def dispatch(req): | |
178 | "run the command specified in req.args" |
|
178 | "run the command specified in req.args" | |
@@ -413,7 +413,7 b' def aliasargs(fn, givenargs):' | |||||
413 | if not util.safehasattr(fn, '_origfunc'): |
|
413 | if not util.safehasattr(fn, '_origfunc'): | |
414 | args = getattr(fn, 'args', args) |
|
414 | args = getattr(fn, 'args', args) | |
415 | if args: |
|
415 | if args: | |
416 | cmd = ' '.join(map(util.shellquote, args)) |
|
416 | cmd = ' '.join(map(procutil.shellquote, args)) | |
417 |
|
417 | |||
418 | nums = [] |
|
418 | nums = [] | |
419 | def replacer(m): |
|
419 | def replacer(m): | |
@@ -443,7 +443,7 b' def aliasinterpolate(name, args, cmd):' | |||||
443 | # parameters, separated out into words. Emulate the same behavior here by |
|
443 | # parameters, separated out into words. Emulate the same behavior here by | |
444 | # quoting the arguments individually. POSIX shells will then typically |
|
444 | # quoting the arguments individually. POSIX shells will then typically | |
445 | # tokenize each argument into exactly one word. |
|
445 | # tokenize each argument into exactly one word. | |
446 | replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args) |
|
446 | replacemap['"$@"'] = ' '.join(procutil.shellquote(arg) for arg in args) | |
447 | # escape '\$' for regex |
|
447 | # escape '\$' for regex | |
448 | regex = '|'.join(replacemap.keys()).replace('$', br'\$') |
|
448 | regex = '|'.join(replacemap.keys()).replace('$', br'\$') | |
449 | r = re.compile(regex) |
|
449 | r = re.compile(regex) |
@@ -32,6 +32,7 b' from . import (' | |||||
32 | ) |
|
32 | ) | |
33 |
|
33 | |||
34 | from .utils import ( |
|
34 | from .utils import ( | |
|
35 | procutil, | |||
35 | stringutil, |
|
36 | stringutil, | |
36 | ) |
|
37 | ) | |
37 |
|
38 | |||
@@ -122,11 +123,11 b' def findexternaltool(ui, tool):' | |||||
122 | continue |
|
123 | continue | |
123 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) |
|
124 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) | |
124 | if p: |
|
125 | if p: | |
125 | p = util.findexe(p + _toolstr(ui, tool, "regappend", "")) |
|
126 | p = procutil.findexe(p + _toolstr(ui, tool, "regappend", "")) | |
126 | if p: |
|
127 | if p: | |
127 | return p |
|
128 | return p | |
128 | exe = _toolstr(ui, tool, "executable", tool) |
|
129 | exe = _toolstr(ui, tool, "executable", tool) | |
129 | return util.findexe(util.expandpath(exe)) |
|
130 | return procutil.findexe(util.expandpath(exe)) | |
130 |
|
131 | |||
131 | def _picktool(repo, ui, path, binary, symlink, changedelete): |
|
132 | def _picktool(repo, ui, path, binary, symlink, changedelete): | |
132 | def supportscd(tool): |
|
133 | def supportscd(tool): | |
@@ -149,7 +150,7 b' def _picktool(repo, ui, path, binary, sy' | |||||
149 | # the nomerge tools are the only tools that support change/delete |
|
150 | # the nomerge tools are the only tools that support change/delete | |
150 | # conflicts |
|
151 | # conflicts | |
151 | pass |
|
152 | pass | |
152 | elif not util.gui() and _toolbool(ui, tool, "gui"): |
|
153 | elif not procutil.gui() and _toolbool(ui, tool, "gui"): | |
153 | ui.warn(_("tool %s requires a GUI\n") % tmsg) |
|
154 | ui.warn(_("tool %s requires a GUI\n") % tmsg) | |
154 | else: |
|
155 | else: | |
155 | return True |
|
156 | return True | |
@@ -164,7 +165,7 b' def _picktool(repo, ui, path, binary, sy' | |||||
164 | return ":prompt", None |
|
165 | return ":prompt", None | |
165 | else: |
|
166 | else: | |
166 | if toolpath: |
|
167 | if toolpath: | |
167 | return (force, util.shellquote(toolpath)) |
|
168 | return (force, procutil.shellquote(toolpath)) | |
168 | else: |
|
169 | else: | |
169 | # mimic HGMERGE if given tool not found |
|
170 | # mimic HGMERGE if given tool not found | |
170 | return (force, force) |
|
171 | return (force, force) | |
@@ -182,7 +183,7 b' def _picktool(repo, ui, path, binary, sy' | |||||
182 | mf = match.match(repo.root, '', [pat]) |
|
183 | mf = match.match(repo.root, '', [pat]) | |
183 | if mf(path) and check(tool, pat, symlink, False, changedelete): |
|
184 | if mf(path) and check(tool, pat, symlink, False, changedelete): | |
184 | toolpath = _findtool(ui, tool) |
|
185 | toolpath = _findtool(ui, tool) | |
185 | return (tool, util.shellquote(toolpath)) |
|
186 | return (tool, procutil.shellquote(toolpath)) | |
186 |
|
187 | |||
187 | # then merge tools |
|
188 | # then merge tools | |
188 | tools = {} |
|
189 | tools = {} | |
@@ -207,7 +208,7 b' def _picktool(repo, ui, path, binary, sy' | |||||
207 | for p, t in tools: |
|
208 | for p, t in tools: | |
208 | if check(t, None, symlink, binary, changedelete): |
|
209 | if check(t, None, symlink, binary, changedelete): | |
209 | toolpath = _findtool(ui, t) |
|
210 | toolpath = _findtool(ui, t) | |
210 | return (t, util.shellquote(toolpath)) |
|
211 | return (t, procutil.shellquote(toolpath)) | |
211 |
|
212 | |||
212 | # internal merge or prompt as last resort |
|
213 | # internal merge or prompt as last resort | |
213 | if symlink or binary or changedelete: |
|
214 | if symlink or binary or changedelete: | |
@@ -547,8 +548,9 b' def _xmerge(repo, mynode, orig, fcd, fco' | |||||
547 | replace = {'local': localpath, 'base': basepath, 'other': otherpath, |
|
548 | replace = {'local': localpath, 'base': basepath, 'other': otherpath, | |
548 | 'output': outpath, 'labellocal': mylabel, |
|
549 | 'output': outpath, 'labellocal': mylabel, | |
549 | 'labelother': otherlabel, 'labelbase': baselabel} |
|
550 | 'labelother': otherlabel, 'labelbase': baselabel} | |
550 |
args = util.interpolate( |
|
551 | args = util.interpolate( | |
551 | lambda s: util.shellquote(util.localpath(s))) |
|
552 | br'\$', replace, args, | |
|
553 | lambda s: procutil.shellquote(util.localpath(s))) | |||
552 | cmd = toolpath + ' ' + args |
|
554 | cmd = toolpath + ' ' + args | |
553 | if _toolbool(ui, tool, "gui"): |
|
555 | if _toolbool(ui, tool, "gui"): | |
554 | repo.ui.status(_('running merge tool %s for file %s\n') % |
|
556 | repo.ui.status(_('running merge tool %s for file %s\n') % |
@@ -15,7 +15,10 b' from ..i18n import _' | |||||
15 | from .. import ( |
|
15 | from .. import ( | |
16 | error, |
|
16 | error, | |
17 | pycompat, |
|
17 | pycompat, | |
18 | util, |
|
18 | ) | |
|
19 | ||||
|
20 | from ..utils import ( | |||
|
21 | procutil, | |||
19 | ) |
|
22 | ) | |
20 |
|
23 | |||
21 | from . import ( |
|
24 | from . import ( | |
@@ -51,7 +54,7 b' class httpservice(object):' | |||||
51 | self.opts = opts |
|
54 | self.opts = opts | |
52 |
|
55 | |||
53 | def init(self): |
|
56 | def init(self): | |
54 | util.setsignalhandler() |
|
57 | procutil.setsignalhandler() | |
55 | self.httpd = server.create_server(self.ui, self.app) |
|
58 | self.httpd = server.create_server(self.ui, self.app) | |
56 |
|
59 | |||
57 | if self.opts['port'] and not self.ui.verbose: |
|
60 | if self.opts['port'] and not self.ui.verbose: |
@@ -12,7 +12,6 b' from __future__ import absolute_import' | |||||
12 |
|
12 | |||
13 | from .. import ( |
|
13 | from .. import ( | |
14 | encoding, |
|
14 | encoding, | |
15 | util, |
|
|||
16 | ) |
|
15 | ) | |
17 |
|
16 | |||
18 | from ..utils import ( |
|
17 | from ..utils import ( | |
@@ -24,8 +23,8 b' from . import (' | |||||
24 | ) |
|
23 | ) | |
25 |
|
24 | |||
26 | def launch(application): |
|
25 | def launch(application): | |
27 | util.setbinary(procutil.stdin) |
|
26 | procutil.setbinary(procutil.stdin) | |
28 | util.setbinary(procutil.stdout) |
|
27 | procutil.setbinary(procutil.stdout) | |
29 |
|
28 | |||
30 | environ = dict(encoding.environ.iteritems()) |
|
29 | environ = dict(encoding.environ.iteritems()) | |
31 | environ.setdefault(r'PATH_INFO', '') |
|
30 | environ.setdefault(r'PATH_INFO', '') |
@@ -44,7 +44,7 b' def _pythonhook(ui, repo, htype, hname, ' | |||||
44 | % (hname, funcname)) |
|
44 | % (hname, funcname)) | |
45 | modname = funcname[:d] |
|
45 | modname = funcname[:d] | |
46 | oldpaths = sys.path |
|
46 | oldpaths = sys.path | |
47 | if util.mainfrozen(): |
|
47 | if procutil.mainfrozen(): | |
48 | # binary installs require sys.path manipulation |
|
48 | # binary installs require sys.path manipulation | |
49 | modpath, modfile = os.path.split(modname) |
|
49 | modpath, modfile = os.path.split(modname) | |
50 | if modpath and modfile: |
|
50 | if modpath and modfile: | |
@@ -154,7 +154,7 b' def _exthook(ui, repo, htype, name, cmd,' | |||||
154 | ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n', |
|
154 | ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n', | |
155 | name, cmd, duration) |
|
155 | name, cmd, duration) | |
156 | if r: |
|
156 | if r: | |
157 | desc, r = util.explainexit(r) |
|
157 | desc, r = procutil.explainexit(r) | |
158 | if throw: |
|
158 | if throw: | |
159 | raise error.HookAbort(_('%s hook %s') % (name, desc)) |
|
159 | raise error.HookAbort(_('%s hook %s') % (name, desc)) | |
160 | ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
|
160 | ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
@@ -65,6 +65,7 b' from . import (' | |||||
65 | vfs as vfsmod, |
|
65 | vfs as vfsmod, | |
66 | ) |
|
66 | ) | |
67 | from .utils import ( |
|
67 | from .utils import ( | |
|
68 | procutil, | |||
68 | stringutil, |
|
69 | stringutil, | |
69 | ) |
|
70 | ) | |
70 |
|
71 | |||
@@ -1106,7 +1107,7 b' class localrepository(object):' | |||||
1106 | params = cmd[len(name):].lstrip() |
|
1107 | params = cmd[len(name):].lstrip() | |
1107 | break |
|
1108 | break | |
1108 | if not fn: |
|
1109 | if not fn: | |
1109 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
1110 | fn = lambda s, c, **kwargs: procutil.filter(s, c) | |
1110 | # Wrap old filters not supporting keyword arguments |
|
1111 | # Wrap old filters not supporting keyword arguments | |
1111 | if not pycompat.getargspec(fn)[2]: |
|
1112 | if not pycompat.getargspec(fn)[2]: | |
1112 | oldfn = fn |
|
1113 | oldfn = fn |
@@ -21,7 +21,10 b' from . import (' | |||||
21 | encoding, |
|
21 | encoding, | |
22 | error, |
|
22 | error, | |
23 | pycompat, |
|
23 | pycompat, | |
24 | util, |
|
24 | ) | |
|
25 | ||||
|
26 | from .utils import ( | |||
|
27 | procutil, | |||
25 | ) |
|
28 | ) | |
26 |
|
29 | |||
27 | def _getlockprefix(): |
|
30 | def _getlockprefix(): | |
@@ -212,8 +215,8 b' class lock(object):' | |||||
212 | self.release() |
|
215 | self.release() | |
213 |
|
216 | |||
214 | def _getpid(self): |
|
217 | def _getpid(self): | |
215 | # wrapper around util.getpid() to make testing easier |
|
218 | # wrapper around procutil.getpid() to make testing easier | |
216 | return util.getpid() |
|
219 | return procutil.getpid() | |
217 |
|
220 | |||
218 | def lock(self): |
|
221 | def lock(self): | |
219 | timeout = self.timeout |
|
222 | timeout = self.timeout | |
@@ -299,7 +302,7 b' class lock(object):' | |||||
299 | pid = int(pid) |
|
302 | pid = int(pid) | |
300 | except ValueError: |
|
303 | except ValueError: | |
301 | return locker |
|
304 | return locker | |
302 | if util.testpid(pid): |
|
305 | if procutil.testpid(pid): | |
303 | return locker |
|
306 | return locker | |
304 | # if locker dead, break lock. must do this with another lock |
|
307 | # if locker dead, break lock. must do this with another lock | |
305 | # held, or can race and break valid lock. |
|
308 | # held, or can race and break valid lock. |
@@ -25,6 +25,7 b' from . import (' | |||||
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
27 | from .utils import ( |
|
27 | from .utils import ( | |
|
28 | procutil, | |||
28 | stringutil, |
|
29 | stringutil, | |
29 | ) |
|
30 | ) | |
30 |
|
31 | |||
@@ -143,13 +144,13 b' def _sendmail(ui, sender, recipients, ms' | |||||
143 | cmdline = '%s -f %s %s' % (program, stringutil.email(sender), |
|
144 | cmdline = '%s -f %s %s' % (program, stringutil.email(sender), | |
144 | ' '.join(map(stringutil.email, recipients))) |
|
145 | ' '.join(map(stringutil.email, recipients))) | |
145 | ui.note(_('sending mail: %s\n') % cmdline) |
|
146 | ui.note(_('sending mail: %s\n') % cmdline) | |
146 | fp = util.popen(cmdline, 'w') |
|
147 | fp = procutil.popen(cmdline, 'w') | |
147 | fp.write(msg) |
|
148 | fp.write(msg) | |
148 | ret = fp.close() |
|
149 | ret = fp.close() | |
149 | if ret: |
|
150 | if ret: | |
150 | raise error.Abort('%s %s' % ( |
|
151 | raise error.Abort('%s %s' % ( | |
151 | os.path.basename(program.split(None, 1)[0]), |
|
152 | os.path.basename(program.split(None, 1)[0]), | |
152 | util.explainexit(ret)[0])) |
|
153 | procutil.explainexit(ret)[0])) | |
153 |
|
154 | |||
154 | def _mbox(mbox, sender, recipients, msg): |
|
155 | def _mbox(mbox, sender, recipients, msg): | |
155 | '''write mails to mbox''' |
|
156 | '''write mails to mbox''' | |
@@ -184,7 +185,7 b' def validateconfig(ui):' | |||||
184 | raise error.Abort(_('smtp specified as email transport, ' |
|
185 | raise error.Abort(_('smtp specified as email transport, ' | |
185 | 'but no smtp host configured')) |
|
186 | 'but no smtp host configured')) | |
186 | else: |
|
187 | else: | |
187 | if not util.findexe(method): |
|
188 | if not procutil.findexe(method): | |
188 | raise error.Abort(_('%r specified as email transport, ' |
|
189 | raise error.Abort(_('%r specified as email transport, ' | |
189 | 'but not in PATH') % method) |
|
190 | 'but not in PATH') % method) | |
190 |
|
191 |
@@ -42,6 +42,7 b' from . import (' | |||||
42 | ) |
|
42 | ) | |
43 | from .utils import ( |
|
43 | from .utils import ( | |
44 | dateutil, |
|
44 | dateutil, | |
|
45 | procutil, | |||
45 | stringutil, |
|
46 | stringutil, | |
46 | ) |
|
47 | ) | |
47 |
|
48 | |||
@@ -2100,9 +2101,9 b' def _externalpatch(ui, repo, patcher, pa' | |||||
2100 | args = [] |
|
2101 | args = [] | |
2101 | cwd = repo.root |
|
2102 | cwd = repo.root | |
2102 | if cwd: |
|
2103 | if cwd: | |
2103 | args.append('-d %s' % util.shellquote(cwd)) |
|
2104 | args.append('-d %s' % procutil.shellquote(cwd)) | |
2104 | fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, |
|
2105 | fp = procutil.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, | |
2105 | util.shellquote(patchname))) |
|
2106 | procutil.shellquote(patchname))) | |
2106 | try: |
|
2107 | try: | |
2107 | for line in util.iterfile(fp): |
|
2108 | for line in util.iterfile(fp): | |
2108 | line = line.rstrip() |
|
2109 | line = line.rstrip() | |
@@ -2130,7 +2131,7 b' def _externalpatch(ui, repo, patcher, pa' | |||||
2130 | code = fp.close() |
|
2131 | code = fp.close() | |
2131 | if code: |
|
2132 | if code: | |
2132 | raise PatchError(_("patch command failed: %s") % |
|
2133 | raise PatchError(_("patch command failed: %s") % | |
2133 | util.explainexit(code)[0]) |
|
2134 | procutil.explainexit(code)[0]) | |
2134 | return fuzz |
|
2135 | return fuzz | |
2135 |
|
2136 | |||
2136 | def patchbackend(ui, backend, patchobj, strip, prefix, files=None, |
|
2137 | def patchbackend(ui, backend, patchobj, strip, prefix, files=None, |
@@ -42,6 +42,7 b' from . import (' | |||||
42 | ) |
|
42 | ) | |
43 |
|
43 | |||
44 | from .utils import ( |
|
44 | from .utils import ( | |
|
45 | procutil, | |||
45 | stringutil, |
|
46 | stringutil, | |
46 | ) |
|
47 | ) | |
47 |
|
48 | |||
@@ -293,7 +294,7 b' def checkportable(ui, f):' | |||||
293 | if abort or warn: |
|
294 | if abort or warn: | |
294 | msg = util.checkwinfilename(f) |
|
295 | msg = util.checkwinfilename(f) | |
295 | if msg: |
|
296 | if msg: | |
296 | msg = "%s: %s" % (msg, util.shellquote(f)) |
|
297 | msg = "%s: %s" % (msg, procutil.shellquote(f)) | |
297 | if abort: |
|
298 | if abort: | |
298 | raise error.Abort(msg) |
|
299 | raise error.Abort(msg) | |
299 | ui.warn(_("warning: %s\n") % msg) |
|
300 | ui.warn(_("warning: %s\n") % msg) | |
@@ -1090,7 +1091,7 b' def extdatasource(repo, source):' | |||||
1090 | # external commands should be run relative to the repo root |
|
1091 | # external commands should be run relative to the repo root | |
1091 | cmd = spec[6:] |
|
1092 | cmd = spec[6:] | |
1092 | proc = subprocess.Popen(cmd, shell=True, bufsize=-1, |
|
1093 | proc = subprocess.Popen(cmd, shell=True, bufsize=-1, | |
1093 | close_fds=util.closefds, |
|
1094 | close_fds=procutil.closefds, | |
1094 | stdout=subprocess.PIPE, cwd=repo.root) |
|
1095 | stdout=subprocess.PIPE, cwd=repo.root) | |
1095 | src = proc.stdout |
|
1096 | src = proc.stdout | |
1096 | else: |
|
1097 | else: | |
@@ -1114,7 +1115,7 b' def extdatasource(repo, source):' | |||||
1114 | src.close() |
|
1115 | src.close() | |
1115 | if proc and proc.returncode != 0: |
|
1116 | if proc and proc.returncode != 0: | |
1116 | raise error.Abort(_("extdata command '%s' failed: %s") |
|
1117 | raise error.Abort(_("extdata command '%s' failed: %s") | |
1117 | % (cmd, util.explainexit(proc.returncode)[0])) |
|
1118 | % (cmd, procutil.explainexit(proc.returncode)[0])) | |
1118 |
|
1119 | |||
1119 | return data |
|
1120 | return data | |
1120 |
|
1121 |
@@ -46,7 +46,7 b' def runservice(opts, parentfn=None, init' | |||||
46 | os.close(lockfd) |
|
46 | os.close(lockfd) | |
47 | try: |
|
47 | try: | |
48 | if not runargs: |
|
48 | if not runargs: | |
49 | runargs = util.hgcmd() + pycompat.sysargv[1:] |
|
49 | runargs = procutil.hgcmd() + pycompat.sysargv[1:] | |
50 | runargs.append('--daemon-postexec=unlink:%s' % lockpath) |
|
50 | runargs.append('--daemon-postexec=unlink:%s' % lockpath) | |
51 | # Don't pass --cwd to the child process, because we've already |
|
51 | # Don't pass --cwd to the child process, because we've already | |
52 | # changed directory. |
|
52 | # changed directory. | |
@@ -59,7 +59,7 b' def runservice(opts, parentfn=None, init' | |||||
59 | break |
|
59 | break | |
60 | def condfn(): |
|
60 | def condfn(): | |
61 | return not os.path.exists(lockpath) |
|
61 | return not os.path.exists(lockpath) | |
62 | pid = util.rundetached(runargs, condfn) |
|
62 | pid = procutil.rundetached(runargs, condfn) | |
63 | if pid < 0: |
|
63 | if pid < 0: | |
64 | raise error.Abort(_('child process failed to start')) |
|
64 | raise error.Abort(_('child process failed to start')) | |
65 | writepid(pid) |
|
65 | writepid(pid) | |
@@ -74,7 +74,7 b' def runservice(opts, parentfn=None, init' | |||||
74 | initfn() |
|
74 | initfn() | |
75 |
|
75 | |||
76 | if not opts['daemon']: |
|
76 | if not opts['daemon']: | |
77 | writepid(util.getpid()) |
|
77 | writepid(procutil.getpid()) | |
78 |
|
78 | |||
79 | if opts['daemon_postexec']: |
|
79 | if opts['daemon_postexec']: | |
80 | try: |
|
80 | try: | |
@@ -90,7 +90,7 b' def runservice(opts, parentfn=None, init' | |||||
90 | elif inst != 'none': |
|
90 | elif inst != 'none': | |
91 | raise error.Abort(_('invalid value for --daemon-postexec: %s') |
|
91 | raise error.Abort(_('invalid value for --daemon-postexec: %s') | |
92 | % inst) |
|
92 | % inst) | |
93 | util.hidewindow() |
|
93 | procutil.hidewindow() | |
94 | procutil.stdout.flush() |
|
94 | procutil.stdout.flush() | |
95 | procutil.stderr.flush() |
|
95 | procutil.stderr.flush() | |
96 |
|
96 |
@@ -19,6 +19,9 b' from . import (' | |||||
19 | wireprotoserver, |
|
19 | wireprotoserver, | |
20 | wireprototypes, |
|
20 | wireprototypes, | |
21 | ) |
|
21 | ) | |
|
22 | from .utils import ( | |||
|
23 | procutil, | |||
|
24 | ) | |||
22 |
|
25 | |||
23 | def _serverquote(s): |
|
26 | def _serverquote(s): | |
24 | """quote a string for the remote shell ... which we assume is sh""" |
|
27 | """quote a string for the remote shell ... which we assume is sh""" | |
@@ -33,7 +36,7 b' def _forwardoutput(ui, pipe):' | |||||
33 |
|
36 | |||
34 | This is non blocking.""" |
|
37 | This is non blocking.""" | |
35 | if pipe: |
|
38 | if pipe: | |
36 | s = util.readpipe(pipe) |
|
39 | s = procutil.readpipe(pipe) | |
37 | if s: |
|
40 | if s: | |
38 | for l in s.splitlines(): |
|
41 | for l in s.splitlines(): | |
39 | ui.status(_("remote: "), l, '\n') |
|
42 | ui.status(_("remote: "), l, '\n') | |
@@ -147,16 +150,16 b' def _makeconnection(ui, sshcmd, args, re' | |||||
147 | cmd = '%s %s %s' % ( |
|
150 | cmd = '%s %s %s' % ( | |
148 | sshcmd, |
|
151 | sshcmd, | |
149 | args, |
|
152 | args, | |
150 | util.shellquote('%s -R %s serve --stdio' % ( |
|
153 | procutil.shellquote('%s -R %s serve --stdio' % ( | |
151 | _serverquote(remotecmd), _serverquote(path)))) |
|
154 | _serverquote(remotecmd), _serverquote(path)))) | |
152 |
|
155 | |||
153 | ui.debug('running %s\n' % cmd) |
|
156 | ui.debug('running %s\n' % cmd) | |
154 | cmd = util.quotecommand(cmd) |
|
157 | cmd = procutil.quotecommand(cmd) | |
155 |
|
158 | |||
156 | # no buffer allow the use of 'select' |
|
159 | # no buffer allow the use of 'select' | |
157 | # feel free to remove buffering and select usage when we ultimately |
|
160 | # feel free to remove buffering and select usage when we ultimately | |
158 | # move to threading. |
|
161 | # move to threading. | |
159 | stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv) |
|
162 | stdin, stdout, stderr, proc = procutil.popen4(cmd, bufsize=0, env=sshenv) | |
160 |
|
163 | |||
161 | return proc, stdin, stdout, stderr |
|
164 | return proc, stdin, stdout, stderr | |
162 |
|
165 | |||
@@ -593,14 +596,14 b' def instance(ui, path, create):' | |||||
593 | sshcmd = ui.config('ui', 'ssh') |
|
596 | sshcmd = ui.config('ui', 'ssh') | |
594 | remotecmd = ui.config('ui', 'remotecmd') |
|
597 | remotecmd = ui.config('ui', 'remotecmd') | |
595 | sshaddenv = dict(ui.configitems('sshenv')) |
|
598 | sshaddenv = dict(ui.configitems('sshenv')) | |
596 | sshenv = util.shellenviron(sshaddenv) |
|
599 | sshenv = procutil.shellenviron(sshaddenv) | |
597 | remotepath = u.path or '.' |
|
600 | remotepath = u.path or '.' | |
598 |
|
601 | |||
599 | args = util.sshargs(sshcmd, u.host, u.user, u.port) |
|
602 | args = procutil.sshargs(sshcmd, u.host, u.user, u.port) | |
600 |
|
603 | |||
601 | if create: |
|
604 | if create: | |
602 | cmd = '%s %s %s' % (sshcmd, args, |
|
605 | cmd = '%s %s %s' % (sshcmd, args, | |
603 | util.shellquote('%s init %s' % |
|
606 | procutil.shellquote('%s init %s' % | |
604 | (_serverquote(remotecmd), _serverquote(remotepath)))) |
|
607 | (_serverquote(remotecmd), _serverquote(remotepath)))) | |
605 | ui.debug('running %s\n' % cmd) |
|
608 | ui.debug('running %s\n' % cmd) | |
606 | res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv) |
|
609 | res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv) |
@@ -22,6 +22,7 b' from . import (' | |||||
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
24 | from .utils import ( |
|
24 | from .utils import ( | |
|
25 | procutil, | |||
25 | stringutil, |
|
26 | stringutil, | |
26 | ) |
|
27 | ) | |
27 |
|
28 | |||
@@ -686,7 +687,7 b' def _plainapplepython():' | |||||
686 | for using system certificate store CAs in addition to the provided |
|
687 | for using system certificate store CAs in addition to the provided | |
687 | cacerts file |
|
688 | cacerts file | |
688 | """ |
|
689 | """ | |
689 | if (not pycompat.isdarwin or util.mainfrozen() or |
|
690 | if (not pycompat.isdarwin or procutil.mainfrozen() or | |
690 | not pycompat.sysexecutable): |
|
691 | not pycompat.sysexecutable): | |
691 | return False |
|
692 | return False | |
692 | exe = os.path.realpath(pycompat.sysexecutable).lower() |
|
693 | exe = os.path.realpath(pycompat.sysexecutable).lower() |
@@ -38,6 +38,7 b' from . import (' | |||||
38 | ) |
|
38 | ) | |
39 | from .utils import ( |
|
39 | from .utils import ( | |
40 | dateutil, |
|
40 | dateutil, | |
|
41 | procutil, | |||
41 | stringutil, |
|
42 | stringutil, | |
42 | ) |
|
43 | ) | |
43 |
|
44 | |||
@@ -912,7 +913,7 b' class svnsubrepo(abstractsubrepo):' | |||||
912 | def __init__(self, ctx, path, state, allowcreate): |
|
913 | def __init__(self, ctx, path, state, allowcreate): | |
913 | super(svnsubrepo, self).__init__(ctx, path) |
|
914 | super(svnsubrepo, self).__init__(ctx, path) | |
914 | self._state = state |
|
915 | self._state = state | |
915 | self._exe = util.findexe('svn') |
|
916 | self._exe = procutil.findexe('svn') | |
916 | if not self._exe: |
|
917 | if not self._exe: | |
917 | raise error.Abort(_("'svn' executable not found for subrepo '%s'") |
|
918 | raise error.Abort(_("'svn' executable not found for subrepo '%s'") | |
918 | % self._path) |
|
919 | % self._path) | |
@@ -942,7 +943,7 b' class svnsubrepo(abstractsubrepo):' | |||||
942 | env['LANG'] = lc_all |
|
943 | env['LANG'] = lc_all | |
943 | del env['LC_ALL'] |
|
944 | del env['LC_ALL'] | |
944 | env['LC_MESSAGES'] = 'C' |
|
945 | env['LC_MESSAGES'] = 'C' | |
945 | p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds, |
|
946 | p = subprocess.Popen(cmd, bufsize=-1, close_fds=procutil.closefds, | |
946 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
|
947 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
947 | universal_newlines=True, env=env, **extrakw) |
|
948 | universal_newlines=True, env=env, **extrakw) | |
948 | stdout, stderr = p.communicate() |
|
949 | stdout, stderr = p.communicate() | |
@@ -1260,7 +1261,7 b' class gitsubrepo(abstractsubrepo):' | |||||
1260 | # the end of git diff arguments is used for paths |
|
1261 | # the end of git diff arguments is used for paths | |
1261 | commands.insert(1, '--color') |
|
1262 | commands.insert(1, '--color') | |
1262 | p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1, |
|
1263 | p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1, | |
1263 | cwd=cwd, env=env, close_fds=util.closefds, |
|
1264 | cwd=cwd, env=env, close_fds=procutil.closefds, | |
1264 | stdout=subprocess.PIPE, stderr=errpipe) |
|
1265 | stdout=subprocess.PIPE, stderr=errpipe) | |
1265 | if stream: |
|
1266 | if stream: | |
1266 | return p.stdout, None |
|
1267 | return p.stdout, None |
@@ -808,7 +808,7 b' class ui(object):' | |||||
808 | user = self.prompt(_("enter a commit username:"), default=None) |
|
808 | user = self.prompt(_("enter a commit username:"), default=None) | |
809 | if user is None and not self.interactive(): |
|
809 | if user is None and not self.interactive(): | |
810 | try: |
|
810 | try: | |
811 | user = '%s@%s' % (util.getuser(), |
|
811 | user = '%s@%s' % (procutil.getuser(), | |
812 | encoding.strtolocal(socket.getfqdn())) |
|
812 | encoding.strtolocal(socket.getfqdn())) | |
813 | self.warn(_("no username found, using '%s' instead\n") % user) |
|
813 | self.warn(_("no username found, using '%s' instead\n") % user) | |
814 | except KeyError: |
|
814 | except KeyError: | |
@@ -992,7 +992,7 b' class ui(object):' | |||||
992 | def _isatty(self, fh): |
|
992 | def _isatty(self, fh): | |
993 | if self.configbool('ui', 'nontty'): |
|
993 | if self.configbool('ui', 'nontty'): | |
994 | return False |
|
994 | return False | |
995 | return util.isatty(fh) |
|
995 | return procutil.isatty(fh) | |
996 |
|
996 | |||
997 | def disablepager(self): |
|
997 | def disablepager(self): | |
998 | self._disablepager = True |
|
998 | self._disablepager = True | |
@@ -1088,7 +1088,7 b' class ui(object):' | |||||
1088 | # user so we can also get sane bad PAGER behavior. MSYS has |
|
1088 | # user so we can also get sane bad PAGER behavior. MSYS has | |
1089 | # `more.exe`, so do a cmd.exe style resolution of the executable to |
|
1089 | # `more.exe`, so do a cmd.exe style resolution of the executable to | |
1090 | # determine which one to use. |
|
1090 | # determine which one to use. | |
1091 | fullcmd = util.findexe(command) |
|
1091 | fullcmd = procutil.findexe(command) | |
1092 | if not fullcmd: |
|
1092 | if not fullcmd: | |
1093 | self.warn(_("missing pager command '%s', skipping pager\n") |
|
1093 | self.warn(_("missing pager command '%s', skipping pager\n") | |
1094 | % command) |
|
1094 | % command) | |
@@ -1099,9 +1099,9 b' class ui(object):' | |||||
1099 | try: |
|
1099 | try: | |
1100 | pager = subprocess.Popen( |
|
1100 | pager = subprocess.Popen( | |
1101 | command, shell=shell, bufsize=-1, |
|
1101 | command, shell=shell, bufsize=-1, | |
1102 | close_fds=util.closefds, stdin=subprocess.PIPE, |
|
1102 | close_fds=procutil.closefds, stdin=subprocess.PIPE, | |
1103 | stdout=procutil.stdout, stderr=procutil.stderr, |
|
1103 | stdout=procutil.stdout, stderr=procutil.stderr, | |
1104 | env=util.shellenviron(env)) |
|
1104 | env=procutil.shellenviron(env)) | |
1105 | except OSError as e: |
|
1105 | except OSError as e: | |
1106 | if e.errno == errno.ENOENT and not shell: |
|
1106 | if e.errno == errno.ENOENT and not shell: | |
1107 | self.warn(_("missing pager command '%s', skipping pager\n") |
|
1107 | self.warn(_("missing pager command '%s', skipping pager\n") | |
@@ -1277,7 +1277,8 b' class ui(object):' | |||||
1277 | # we use rawinput() only if call_readline() will be invoked by |
|
1277 | # we use rawinput() only if call_readline() will be invoked by | |
1278 | # PyOS_Readline(), so no I/O will be made at Python layer. |
|
1278 | # PyOS_Readline(), so no I/O will be made at Python layer. | |
1279 | usereadline = (self._isatty(self.fin) and self._isatty(self.fout) |
|
1279 | usereadline = (self._isatty(self.fin) and self._isatty(self.fout) | |
1280 |
and util.isstdin(self.fin) |
|
1280 | and procutil.isstdin(self.fin) | |
|
1281 | and procutil.isstdout(self.fout)) | |||
1281 | if usereadline: |
|
1282 | if usereadline: | |
1282 | try: |
|
1283 | try: | |
1283 | # magically add command line editing support, where |
|
1284 | # magically add command line editing support, where | |
@@ -1504,7 +1505,7 b' class ui(object):' | |||||
1504 | rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out) |
|
1505 | rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out) | |
1505 | if rc and onerr: |
|
1506 | if rc and onerr: | |
1506 | errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), |
|
1507 | errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), | |
1507 | util.explainexit(rc)[0]) |
|
1508 | procutil.explainexit(rc)[0]) | |
1508 | if errprefix: |
|
1509 | if errprefix: | |
1509 | errmsg = '%s: %s' % (errprefix, errmsg) |
|
1510 | errmsg = '%s: %s' % (errprefix, errmsg) | |
1510 | raise onerr(errmsg) |
|
1511 | raise onerr(errmsg) | |
@@ -1513,7 +1514,7 b' class ui(object):' | |||||
1513 | def _runsystem(self, cmd, environ, cwd, out): |
|
1514 | def _runsystem(self, cmd, environ, cwd, out): | |
1514 | """actually execute the given shell command (can be overridden by |
|
1515 | """actually execute the given shell command (can be overridden by | |
1515 | extensions like chg)""" |
|
1516 | extensions like chg)""" | |
1516 | return util.system(cmd, environ=environ, cwd=cwd, out=out) |
|
1517 | return procutil.system(cmd, environ=environ, cwd=cwd, out=out) | |
1517 |
|
1518 | |||
1518 | def traceback(self, exc=None, force=False): |
|
1519 | def traceback(self, exc=None, force=False): | |
1519 | '''print exception traceback if traceback printing enabled or forced. |
|
1520 | '''print exception traceback if traceback printing enabled or forced. |
@@ -22,6 +22,9 b' from . import (' | |||||
22 | wireprotoframing, |
|
22 | wireprotoframing, | |
23 | wireprototypes, |
|
23 | wireprototypes, | |
24 | ) |
|
24 | ) | |
|
25 | from .utils import ( | |||
|
26 | procutil, | |||
|
27 | ) | |||
25 |
|
28 | |||
26 | stringio = util.stringio |
|
29 | stringio = util.stringio | |
27 |
|
30 | |||
@@ -1030,8 +1033,8 b' class sshserver(object):' | |||||
1030 | ui.fout = repo.ui.fout = ui.ferr |
|
1033 | ui.fout = repo.ui.fout = ui.ferr | |
1031 |
|
1034 | |||
1032 | # Prevent insertion/deletion of CRs |
|
1035 | # Prevent insertion/deletion of CRs | |
1033 | util.setbinary(self._fin) |
|
1036 | procutil.setbinary(self._fin) | |
1034 | util.setbinary(self._fout) |
|
1037 | procutil.setbinary(self._fout) | |
1035 |
|
1038 | |||
1036 | def serve_forever(self): |
|
1039 | def serve_forever(self): | |
1037 | self.serveuntil(threading.Event()) |
|
1040 | self.serveuntil(threading.Event()) |
@@ -1,6 +1,6 b'' | |||||
1 | from __future__ import absolute_import |
|
1 | from __future__ import absolute_import | |
2 | from mercurial import ( |
|
2 | from mercurial.utils import ( | |
3 | util, |
|
3 | procutil, | |
4 | ) |
|
4 | ) | |
5 |
|
5 | |||
6 | # XXX: we should probably offer a devel option to do this in blackbox directly |
|
6 | # XXX: we should probably offer a devel option to do this in blackbox directly | |
@@ -11,5 +11,5 b' def getpid():' | |||||
11 |
|
11 | |||
12 | # mock the date and user apis so the output is always the same |
|
12 | # mock the date and user apis so the output is always the same | |
13 | def uisetup(ui): |
|
13 | def uisetup(ui): | |
14 | util.getuser = getuser |
|
14 | procutil.getuser = getuser | |
15 | util.getpid = getpid |
|
15 | procutil.getpid = getpid |
@@ -23,11 +23,12 b'' | |||||
23 |
|
23 | |||
24 | > cat > posixgetuser.py <<'EOF' |
|
24 | > cat > posixgetuser.py <<'EOF' | |
25 | > import getpass |
|
25 | > import getpass | |
26 |
> from mercurial import pycompat |
|
26 | > from mercurial import pycompat | |
|
27 | > from mercurial.utils import procutil | |||
27 | > def posixgetuser(): |
|
28 | > def posixgetuser(): | |
28 | > return pycompat.fsencode(getpass.getuser()) |
|
29 | > return pycompat.fsencode(getpass.getuser()) | |
29 | > if not pycompat.isposix: |
|
30 | > if not pycompat.isposix: | |
30 | > util.getuser = posixgetuser # forcibly trust $LOGNAME |
|
31 | > procutil.getuser = posixgetuser # forcibly trust $LOGNAME | |
31 | > EOF |
|
32 | > EOF | |
32 |
|
33 | |||
33 | > init_config() |
|
34 | > init_config() |
@@ -910,9 +910,9 b' Annotate with orphaned CR (issue5798)' | |||||
910 |
|
910 | |||
911 | $ cat <<'EOF' >> "$TESTTMP/substcr.py" |
|
911 | $ cat <<'EOF' >> "$TESTTMP/substcr.py" | |
912 | > import sys |
|
912 | > import sys | |
913 | > from mercurial import util |
|
913 | > from mercurial.utils import procutil | |
914 | > util.setbinary(sys.stdin) |
|
914 | > procutil.setbinary(sys.stdin) | |
915 | > util.setbinary(sys.stdout) |
|
915 | > procutil.setbinary(sys.stdout) | |
916 | > stdin = getattr(sys.stdin, 'buffer', sys.stdin) |
|
916 | > stdin = getattr(sys.stdin, 'buffer', sys.stdin) | |
917 | > stdout = getattr(sys.stdout, 'buffer', sys.stdout) |
|
917 | > stdout = getattr(sys.stdout, 'buffer', sys.stdout) | |
918 | > stdout.write(stdin.read().replace(b'\r', b'[CR]')) |
|
918 | > stdout.write(stdin.read().replace(b'\r', b'[CR]')) |
@@ -1,9 +1,10 b'' | |||||
1 | Journal extension test: tests the share extension support |
|
1 | Journal extension test: tests the share extension support | |
2 |
|
2 | |||
3 | $ cat >> testmocks.py << EOF |
|
3 | $ cat >> testmocks.py << EOF | |
4 | > # mock out util.getuser() and util.makedate() to supply testable values |
|
4 | > # mock out procutil.getuser() and util.makedate() to supply testable values | |
5 | > import os |
|
5 | > import os | |
6 | > from mercurial import util |
|
6 | > from mercurial import util | |
|
7 | > from mercurial.utils import procutil | |||
7 | > def mockgetuser(): |
|
8 | > def mockgetuser(): | |
8 | > return 'foobar' |
|
9 | > return 'foobar' | |
9 | > |
|
10 | > | |
@@ -18,7 +19,7 b' Journal extension test: tests the share ' | |||||
18 | > timef.write(str(time)) |
|
19 | > timef.write(str(time)) | |
19 | > return (time, 0) |
|
20 | > return (time, 0) | |
20 | > |
|
21 | > | |
21 | > util.getuser = mockgetuser |
|
22 | > procutil.getuser = mockgetuser | |
22 | > util.makedate = mockmakedate |
|
23 | > util.makedate = mockmakedate | |
23 | > EOF |
|
24 | > EOF | |
24 |
|
25 |
@@ -1,10 +1,10 b'' | |||||
1 | Tests for the journal extension; records bookmark locations. |
|
1 | Tests for the journal extension; records bookmark locations. | |
2 |
|
2 | |||
3 | $ cat >> testmocks.py << EOF |
|
3 | $ cat >> testmocks.py << EOF | |
4 | > # mock out util.getuser() and util.makedate() to supply testable values |
|
4 | > # mock out procutil.getuser() and util.makedate() to supply testable values | |
5 | > import os |
|
5 | > import os | |
6 | > from mercurial import util |
|
6 | > from mercurial import util | |
7 | > from mercurial.utils import dateutil |
|
7 | > from mercurial.utils import dateutil, procutil | |
8 | > def mockgetuser(): |
|
8 | > def mockgetuser(): | |
9 | > return 'foobar' |
|
9 | > return 'foobar' | |
10 | > |
|
10 | > | |
@@ -19,7 +19,7 b' Tests for the journal extension; records' | |||||
19 | > timef.write(str(time)) |
|
19 | > timef.write(str(time)) | |
20 | > return (time, 0) |
|
20 | > return (time, 0) | |
21 | > |
|
21 | > | |
22 | > util.getuser = mockgetuser |
|
22 | > procutil.getuser = mockgetuser | |
23 | > dateutil.makedate = mockmakedate |
|
23 | > dateutil.makedate = mockmakedate | |
24 | > EOF |
|
24 | > EOF | |
25 |
|
25 |
@@ -6,11 +6,14 b' import unittest' | |||||
6 | import silenttestrunner |
|
6 | import silenttestrunner | |
7 |
|
7 | |||
8 | from mercurial import ( |
|
8 | from mercurial import ( | |
9 | util, |
|
|||
10 | wireproto, |
|
9 | wireproto, | |
11 | wireprotoserver, |
|
10 | wireprotoserver, | |
12 | ) |
|
11 | ) | |
13 |
|
12 | |||
|
13 | from mercurial.utils import ( | |||
|
14 | procutil, | |||
|
15 | ) | |||
|
16 | ||||
14 | class SSHServerGetArgsTests(unittest.TestCase): |
|
17 | class SSHServerGetArgsTests(unittest.TestCase): | |
15 | def testparseknown(self): |
|
18 | def testparseknown(self): | |
16 | tests = [ |
|
19 | tests = [ | |
@@ -46,5 +49,5 b' class mockui(object):' | |||||
46 |
|
49 | |||
47 | if __name__ == '__main__': |
|
50 | if __name__ == '__main__': | |
48 | # Don't call into msvcrt to set BytesIO to binary mode |
|
51 | # Don't call into msvcrt to set BytesIO to binary mode | |
49 | util.setbinary = lambda fp: True |
|
52 | procutil.setbinary = lambda fp: True | |
50 | silenttestrunner.main(__name__) |
|
53 | silenttestrunner.main(__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now