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