--- a/contrib/dumprevlog Sat Mar 24 15:09:33 2018 +0900
+++ b/contrib/dumprevlog Sat Mar 24 15:10:51 2018 +0900
@@ -8,11 +8,13 @@
from mercurial import (
node,
revlog,
- util,
+)
+from mercurial.utils import (
+ procutil,
)
for fp in (sys.stdin, sys.stdout, sys.stderr):
- util.setbinary(fp)
+ procutil.setbinary(fp)
def binopen(path, mode='rb'):
if 'b' not in mode:
--- a/contrib/phabricator.py Sat Mar 24 15:09:33 2018 +0900
+++ b/contrib/phabricator.py Sat Mar 24 15:10:51 2018 +0900
@@ -66,6 +66,9 @@
url as urlmod,
util,
)
+from mercurial.utils import (
+ procutil,
+)
cmdtable = {}
command = registrar.command(cmdtable)
@@ -161,7 +164,8 @@
data = urlencodenested(params)
curlcmd = repo.ui.config('phabricator', 'curlcmd')
if curlcmd:
- sin, sout = util.popen2('%s -d @- %s' % (curlcmd, util.shellquote(url)))
+ sin, sout = procutil.popen2('%s -d @- %s'
+ % (curlcmd, procutil.shellquote(url)))
sin.write(data)
sin.close()
body = sout.read()
--- a/contrib/simplemerge Sat Mar 24 15:09:33 2018 +0900
+++ b/contrib/simplemerge Sat Mar 24 15:10:51 2018 +0900
@@ -14,7 +14,9 @@
fancyopts,
simplemerge,
ui as uimod,
- util,
+)
+from mercurial.utils import (
+ procutil,
)
options = [('L', 'label', [], _('labels to use on conflict markers')),
@@ -52,7 +54,7 @@
try:
for fp in (sys.stdin, sys.stdout, sys.stderr):
- util.setbinary(fp)
+ procutil.setbinary(fp)
opts = {}
try:
--- a/contrib/undumprevlog Sat Mar 24 15:09:33 2018 +0900
+++ b/contrib/undumprevlog Sat Mar 24 15:10:51 2018 +0900
@@ -10,12 +10,14 @@
node,
revlog,
transaction,
- util,
vfs as vfsmod,
)
+from mercurial.utils import (
+ procutil,
+)
for fp in (sys.stdin, sys.stdout, sys.stderr):
- util.setbinary(fp)
+ procutil.setbinary(fp)
opener = vfsmod.vfs('.', False)
tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
--- a/hgext/acl.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/acl.py Sat Mar 24 15:10:51 2018 +0900
@@ -201,6 +201,9 @@
registrar,
util,
)
+from mercurial.utils import (
+ procutil,
+)
urlreq = util.urlreq
@@ -338,7 +341,7 @@
user = urlreq.unquote(url[3])
if user is None:
- user = util.getuser()
+ user = procutil.getuser()
ui.debug('acl: checking access for user "%s"\n' % user)
--- a/hgext/blackbox.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/blackbox.py Sat Mar 24 15:10:51 2018 +0900
@@ -49,7 +49,10 @@
ui as uimod,
util,
)
-from mercurial.utils import dateutil
+from mercurial.utils import (
+ dateutil,
+ procutil,
+)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -166,8 +169,8 @@
ui._bbinlog = True
default = self.configdate('devel', 'default-date')
date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S')
- user = util.getuser()
- pid = '%d' % util.getpid()
+ user = procutil.getuser()
+ pid = '%d' % procutil.getpid()
formattedmsg = msg[0] % msg[1:]
rev = '(unknown)'
changed = ''
--- a/hgext/bugzilla.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/bugzilla.py Sat Mar 24 15:10:51 2018 +0900
@@ -308,6 +308,7 @@
util,
)
from mercurial.utils import (
+ procutil,
stringutil,
)
@@ -527,13 +528,13 @@
except TypeError:
cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user}
self.ui.note(_('running notify command %s\n') % cmd)
- fp = util.popen('(%s) 2>&1' % cmd)
+ fp = procutil.popen('(%s) 2>&1' % cmd)
out = fp.read()
ret = fp.close()
if ret:
self.ui.warn(out)
raise error.Abort(_('bugzilla notify command %s') %
- util.explainexit(ret)[0])
+ procutil.explainexit(ret)[0])
self.ui.status(_('done\n'))
def get_user_id(self, user):
--- a/hgext/convert/common.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/common.py Sat Mar 24 15:10:51 2018 +0900
@@ -22,6 +22,9 @@
pycompat,
util,
)
+from mercurial.utils import (
+ procutil,
+)
pickle = util.pickle
propertycache = util.propertycache
@@ -96,7 +99,7 @@
def checktool(exe, name=None, abort=True):
name = name or exe
- if not util.findexe(exe):
+ if not procutil.findexe(exe):
if abort:
exc = error.Abort
else:
@@ -390,7 +393,7 @@
cmdline[-1] += '=' + v
except TypeError:
pass
- cmdline = [util.shellquote(arg) for arg in cmdline]
+ cmdline = [procutil.shellquote(arg) for arg in cmdline]
if not self.ui.debugflag:
cmdline += ['2>', pycompat.bytestr(os.devnull)]
cmdline = ' '.join(cmdline)
@@ -399,16 +402,16 @@
def _run(self, cmd, *args, **kwargs):
def popen(cmdline):
p = subprocess.Popen(cmdline, shell=True, bufsize=-1,
- close_fds=util.closefds,
- stdout=subprocess.PIPE)
+ close_fds=procutil.closefds,
+ stdout=subprocess.PIPE)
return p
return self._dorun(popen, cmd, *args, **kwargs)
def _run2(self, cmd, *args, **kwargs):
- return self._dorun(util.popen2, cmd, *args, **kwargs)
+ return self._dorun(procutil.popen2, cmd, *args, **kwargs)
def _run3(self, cmd, *args, **kwargs):
- return self._dorun(util.popen3, cmd, *args, **kwargs)
+ return self._dorun(procutil.popen3, cmd, *args, **kwargs)
def _dorun(self, openfunc, cmd, *args, **kwargs):
cmdline = self._cmdline(cmd, *args, **kwargs)
@@ -437,7 +440,7 @@
if output:
self.ui.warn(_('%s error:\n') % self.command)
self.ui.warn(output)
- msg = util.explainexit(status)[0]
+ msg = procutil.explainexit(status)[0]
raise error.Abort('%s %s' % (self.command, msg))
def run0(self, cmd, *args, **kwargs):
--- a/hgext/convert/cvs.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/cvs.py Sat Mar 24 15:10:51 2018 +0900
@@ -18,7 +18,10 @@
pycompat,
util,
)
-from mercurial.utils import dateutil
+from mercurial.utils import (
+ dateutil,
+ procutil,
+)
from . import (
common,
@@ -197,9 +200,9 @@
cmd = [rsh, host] + cmd
# popen2 does not support argument lists under Windows
- cmd = [util.shellquote(arg) for arg in cmd]
- cmd = util.quotecommand(' '.join(cmd))
- self.writep, self.readp = util.popen2(cmd)
+ cmd = [procutil.shellquote(arg) for arg in cmd]
+ cmd = procutil.quotecommand(' '.join(cmd))
+ self.writep, self.readp = procutil.popen2(cmd)
self.realroot = root
--- a/hgext/convert/cvsps.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/cvsps.py Sat Mar 24 15:10:51 2018 +0900
@@ -19,6 +19,7 @@
)
from mercurial.utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -223,11 +224,11 @@
state = 0
store = False # set when a new record can be appended
- cmd = [util.shellquote(arg) for arg in cmd]
+ cmd = [procutil.shellquote(arg) for arg in cmd]
ui.note(_("running %s\n") % (' '.join(cmd)))
ui.debug("prefix=%r directory=%r root=%r\n" % (prefix, directory, root))
- pfp = util.popen(' '.join(cmd))
+ pfp = procutil.popen(' '.join(cmd))
peek = pfp.readline()
while True:
line = peek
--- a/hgext/convert/gnuarch.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/gnuarch.py Sat Mar 24 15:10:51 2018 +0900
@@ -17,9 +17,11 @@
from mercurial import (
encoding,
error,
- util,
)
-from mercurial.utils import dateutil
+from mercurial.utils import (
+ dateutil,
+ procutil,
+)
from . import common
class gnuarch_source(common.converter_source, common.commandline):
@@ -46,10 +48,10 @@
# Could use checktool, but we want to check for baz or tla.
self.execmd = None
- if util.findexe('baz'):
+ if procutil.findexe('baz'):
self.execmd = 'baz'
else:
- if util.findexe('tla'):
+ if procutil.findexe('tla'):
self.execmd = 'tla'
else:
raise error.Abort(_('cannot find a GNU Arch tool'))
@@ -195,9 +197,9 @@
def _execute(self, cmd, *args, **kwargs):
cmdline = [self.execmd, cmd]
cmdline += args
- cmdline = [util.shellquote(arg) for arg in cmdline]
+ cmdline = [procutil.shellquote(arg) for arg in cmdline]
cmdline += ['>', os.devnull, '2>', os.devnull]
- cmdline = util.quotecommand(' '.join(cmdline))
+ cmdline = procutil.quotecommand(' '.join(cmdline))
self.ui.debug(cmdline, '\n')
return os.system(cmdline)
--- a/hgext/convert/p4.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/p4.py Sat Mar 24 15:10:51 2018 +0900
@@ -16,6 +16,7 @@
)
from mercurial.utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -89,8 +90,8 @@
def _parse_view(self, path):
"Read changes affecting the path"
- cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
- stdout = util.popen(cmd, mode='rb')
+ cmd = 'p4 -G changes -s submitted %s' % procutil.shellquote(path)
+ stdout = procutil.popen(cmd, mode='rb')
p4changes = {}
for d in loaditer(stdout):
c = d.get("change", None)
@@ -118,8 +119,8 @@
else:
views = {"//": ""}
else:
- cmd = 'p4 -G client -o %s' % util.shellquote(path)
- clientspec = marshal.load(util.popen(cmd, mode='rb'))
+ cmd = 'p4 -G client -o %s' % procutil.shellquote(path)
+ clientspec = marshal.load(procutil.popen(cmd, mode='rb'))
views = {}
for client in clientspec:
@@ -198,8 +199,8 @@
oldname = depotname[filename]
flcmd = 'p4 -G filelog %s' \
- % util.shellquote(oldname)
- flstdout = util.popen(flcmd, mode='rb')
+ % procutil.shellquote(oldname)
+ flstdout = procutil.popen(flcmd, mode='rb')
copiedfilename = None
for d in loaditer(flstdout):
@@ -272,11 +273,11 @@
def getfile(self, name, rev):
cmd = 'p4 -G print %s' \
- % util.shellquote("%s#%s" % (self.depotname[name], rev))
+ % procutil.shellquote("%s#%s" % (self.depotname[name], rev))
lasterror = None
while True:
- stdout = util.popen(cmd, mode='rb')
+ stdout = procutil.popen(cmd, mode='rb')
mode = None
contents = []
@@ -358,7 +359,7 @@
"""Return an output of `p4 describe` including author, commit date as
a dictionary."""
cmd = "p4 -G describe -s %s" % rev
- stdout = util.popen(cmd, mode='rb')
+ stdout = procutil.popen(cmd, mode='rb')
return marshal.load(stdout)
def getcommit(self, rev):
--- a/hgext/convert/subversion.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/convert/subversion.py Sat Mar 24 15:10:51 2018 +0900
@@ -18,6 +18,7 @@
)
from mercurial.utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -1069,9 +1070,9 @@
if not self.ui.configbool('convert', 'svn.debugsvnlog'):
return directlogstream(*args)
arg = encodeargs(args)
- hgexe = util.hgexecutable()
- cmd = '%s debugsvnlog' % util.shellquote(hgexe)
- stdin, stdout = util.popen2(util.quotecommand(cmd))
+ hgexe = procutil.hgexecutable()
+ cmd = '%s debugsvnlog' % procutil.shellquote(hgexe)
+ stdin, stdout = procutil.popen2(procutil.quotecommand(cmd))
stdin.write(arg)
try:
stdin.close()
--- a/hgext/extdiff.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/extdiff.py Sat Mar 24 15:10:51 2018 +0900
@@ -83,6 +83,7 @@
util,
)
from mercurial.utils import (
+ procutil,
stringutil,
)
@@ -280,7 +281,7 @@
key = match.group(3)
if not do3way and key == 'parent2':
return pre
- return pre + util.shellquote(replace[key])
+ return pre + procutil.shellquote(replace[key])
# Match parent2 first, so 'parent1?' will match both parent1 and parent
regex = (br'''(['"]?)([^\s'"$]*)'''
@@ -349,7 +350,7 @@
if not program:
program = 'diff'
option = option or ['-Npru']
- cmdline = ' '.join(map(util.shellquote, [program] + option))
+ cmdline = ' '.join(map(procutil.shellquote, [program] + option))
return dodiff(ui, repo, cmdline, pats, opts)
class savedcmd(object):
@@ -376,7 +377,7 @@
def __call__(self, ui, repo, *pats, **opts):
opts = pycompat.byteskwargs(opts)
- options = ' '.join(map(util.shellquote, opts['option']))
+ options = ' '.join(map(procutil.shellquote, opts['option']))
if options:
options = ' ' + options
return dodiff(ui, repo, self._cmdline + options, pats, opts)
@@ -387,11 +388,11 @@
if cmd.startswith('cmd.'):
cmd = cmd[4:]
if not path:
- path = util.findexe(cmd)
+ path = procutil.findexe(cmd)
if path is None:
path = filemerge.findexternaltool(ui, cmd) or cmd
diffopts = ui.config('extdiff', 'opts.' + cmd)
- cmdline = util.shellquote(path)
+ cmdline = procutil.shellquote(path)
if diffopts:
cmdline += ' ' + diffopts
elif cmd.startswith('opts.'):
@@ -403,10 +404,10 @@
diffopts = len(pycompat.shlexsplit(cmdline)) > 1
else:
# case "cmd ="
- path = util.findexe(cmd)
+ path = procutil.findexe(cmd)
if path is None:
path = filemerge.findexternaltool(ui, cmd) or cmd
- cmdline = util.shellquote(path)
+ cmdline = procutil.shellquote(path)
diffopts = False
# look for diff arguments in [diff-tools] then [merge-tools]
if not diffopts:
--- a/hgext/githelp.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/githelp.py Sat Mar 24 15:10:51 2018 +0900
@@ -26,7 +26,9 @@
error,
fancyopts,
registrar,
- util,
+)
+from mercurial.utils import (
+ procutil,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -625,7 +627,7 @@
cmd['-0'] = None
cmd.append('.')
for include in args:
- cmd['-I'] = util.shellquote(include)
+ cmd['-I'] = procutil.shellquote(include)
ui.status((bytes(cmd)), "\n")
--- a/hgext/gpg.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/gpg.py Sat Mar 24 15:10:51 2018 +0900
@@ -19,9 +19,11 @@
node as hgnode,
pycompat,
registrar,
- util,
)
-from mercurial.utils import dateutil
+from mercurial.utils import (
+ dateutil,
+ procutil,
+)
cmdtable = {}
command = registrar.command(cmdtable)
@@ -52,7 +54,7 @@
def sign(self, data):
gpgcmd = "%s --sign --detach-sign%s" % (self.path, self.key)
- return util.filter(data, gpgcmd)
+ return procutil.filter(data, gpgcmd)
def verify(self, data, sig):
""" returns of the good and bad signatures"""
@@ -69,7 +71,7 @@
fp.close()
gpgcmd = ("%s --logger-fd 1 --status-fd 1 --verify "
"\"%s\" \"%s\"" % (self.path, sigfile, datafile))
- ret = util.filter("", gpgcmd)
+ ret = procutil.filter("", gpgcmd)
finally:
for f in (sigfile, datafile):
try:
--- a/hgext/journal.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/journal.py Sat Mar 24 15:10:51 2018 +0900
@@ -38,6 +38,7 @@
)
from mercurial.utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -255,7 +256,7 @@
_lockref = None
def __init__(self, repo):
- self.user = util.getuser()
+ self.user = procutil.getuser()
self.ui = repo.ui
self.vfs = repo.vfs
@@ -272,7 +273,7 @@
@property
def command(self):
commandstr = ' '.join(
- map(util.shellquote, journalstorage._currentcommand))
+ map(procutil.shellquote, journalstorage._currentcommand))
if '\n' in commandstr:
# truncate multi-line commands
commandstr = commandstr.partition('\n')[0] + ' ...'
--- a/hgext/transplant.py Sat Mar 24 15:09:33 2018 +0900
+++ b/hgext/transplant.py Sat Mar 24 15:10:51 2018 +0900
@@ -39,6 +39,7 @@
vfs as vfsmod,
)
from mercurial.utils import (
+ procutil,
stringutil,
)
@@ -271,8 +272,9 @@
fp.close()
try:
- self.ui.system('%s %s %s' % (filter, util.shellquote(headerfile),
- util.shellquote(patchfile)),
+ self.ui.system('%s %s %s' % (filter,
+ procutil.shellquote(headerfile),
+ procutil.shellquote(patchfile)),
environ={'HGUSER': changelog[1],
'HGREVISION': nodemod.hex(node),
},
--- a/mercurial/chgserver.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/chgserver.py Sat Mar 24 15:10:51 2018 +0900
@@ -205,12 +205,12 @@
if (out is not self.fout
or not util.safehasattr(self.fout, 'fileno')
or self.fout.fileno() != procutil.stdout.fileno()):
- return util.system(cmd, environ=environ, cwd=cwd, out=out)
+ return procutil.system(cmd, environ=environ, cwd=cwd, out=out)
self.flush()
- return self._csystem(cmd, util.shellenviron(environ), cwd)
+ return self._csystem(cmd, procutil.shellenviron(environ), cwd)
def _runpager(self, cmd, env=None):
- self._csystem(cmd, util.shellenviron(env), type='pager',
+ self._csystem(cmd, procutil.shellenviron(env), type='pager',
cmdtable={'attachio': attachio})
return True
@@ -271,7 +271,7 @@
self.channel = channel
def __call__(self, cmd, environ, cwd=None, type='system', cmdtable=None):
- args = [type, util.quotecommand(cmd), os.path.abspath(cwd or '.')]
+ args = [type, procutil.quotecommand(cmd), os.path.abspath(cwd or '.')]
args.extend('%s=%s' % (k, v) for k, v in environ.iteritems())
data = '\0'.join(args)
self.out.write(struct.pack('>cI', self.channel, len(data)))
@@ -477,12 +477,12 @@
'setenv': setenv,
'setumask': setumask})
- if util.safehasattr(util, 'setprocname'):
+ if util.safehasattr(procutil, 'setprocname'):
def setprocname(self):
"""Change process title"""
name = self._readstr()
_log('setprocname: %r\n' % name)
- util.setprocname(name)
+ procutil.setprocname(name)
capabilities['setprocname'] = setprocname
def _tempaddress(address):
--- a/mercurial/commands.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/commands.py Sat Mar 24 15:10:51 2018 +0900
@@ -63,6 +63,7 @@
)
from .utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -2316,9 +2317,9 @@
repo.vfs.write('graftstate', ''.join(nodelines))
extra = ''
if opts.get('user'):
- extra += ' --user %s' % util.shellquote(opts['user'])
+ extra += ' --user %s' % procutil.shellquote(opts['user'])
if opts.get('date'):
- extra += ' --date %s' % util.shellquote(opts['date'])
+ extra += ' --date %s' % procutil.shellquote(opts['date'])
if opts.get('log'):
extra += ' --log'
hint=_("use 'hg resolve' and 'hg graft --continue%s'") % extra
--- a/mercurial/commandserver.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/commandserver.py Sat Mar 24 15:10:51 2018 +0900
@@ -288,7 +288,7 @@
hellomsg += '\n'
hellomsg += 'encoding: ' + encoding.encoding
hellomsg += '\n'
- hellomsg += 'pid: %d' % util.getpid()
+ hellomsg += 'pid: %d' % procutil.getpid()
if util.safehasattr(os, 'getpgid'):
hellomsg += '\n'
hellomsg += 'pgid: %d' % os.getpgid(0)
@@ -457,8 +457,8 @@
def init(self):
self._sock = socket.socket(socket.AF_UNIX)
self._servicehandler.bindsocket(self._sock, self.address)
- if util.safehasattr(util, 'unblocksignal'):
- util.unblocksignal(signal.SIGCHLD)
+ if util.safehasattr(procutil, 'unblocksignal'):
+ procutil.unblocksignal(signal.SIGCHLD)
o = signal.signal(signal.SIGCHLD, self._sigchldhandler)
self._oldsigchldhandler = o
self._socketunlinked = False
--- a/mercurial/debugcommands.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/debugcommands.py Sat Mar 24 15:10:51 2018 +0900
@@ -83,6 +83,7 @@
)
from .utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -1254,9 +1255,9 @@
# editor
editor = ui.geteditor()
editor = util.expandpath(editor)
- editorbin = util.shellsplit(editor)[0]
+ editorbin = procutil.shellsplit(editor)[0]
fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
- cmdpath = util.findexe(editorbin)
+ cmdpath = procutil.findexe(editorbin)
fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
_(" No commit editor set and can't find %s in PATH\n"
" (specify a commit editor in your configuration"
@@ -2813,7 +2814,7 @@
# We start the SSH server in its own process so there is process
# separation. This prevents a whole class of potential bugs around
# shared state from interfering with server operation.
- args = util.hgcmd() + [
+ args = procutil.hgcmd() + [
'-R', repo.root,
'debugserve', '--sshstdio',
]
--- a/mercurial/dispatch.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/dispatch.py Sat Mar 24 15:10:51 2018 +0900
@@ -137,7 +137,7 @@
else:
def _initstdio():
for fp in (sys.stdin, sys.stdout, sys.stderr):
- util.setbinary(fp)
+ procutil.setbinary(fp)
def _silencestdio():
pass
@@ -172,7 +172,7 @@
write(_("(%s)\n") % inst.hint)
def _formatargs(args):
- return ' '.join(util.shellquote(a) for a in args)
+ return ' '.join(procutil.shellquote(a) for a in args)
def dispatch(req):
"run the command specified in req.args"
@@ -413,7 +413,7 @@
if not util.safehasattr(fn, '_origfunc'):
args = getattr(fn, 'args', args)
if args:
- cmd = ' '.join(map(util.shellquote, args))
+ cmd = ' '.join(map(procutil.shellquote, args))
nums = []
def replacer(m):
@@ -443,7 +443,7 @@
# parameters, separated out into words. Emulate the same behavior here by
# quoting the arguments individually. POSIX shells will then typically
# tokenize each argument into exactly one word.
- replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
+ replacemap['"$@"'] = ' '.join(procutil.shellquote(arg) for arg in args)
# escape '\$' for regex
regex = '|'.join(replacemap.keys()).replace('$', br'\$')
r = re.compile(regex)
--- a/mercurial/filemerge.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/filemerge.py Sat Mar 24 15:10:51 2018 +0900
@@ -32,6 +32,7 @@
)
from .utils import (
+ procutil,
stringutil,
)
@@ -122,11 +123,11 @@
continue
p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
if p:
- p = util.findexe(p + _toolstr(ui, tool, "regappend", ""))
+ p = procutil.findexe(p + _toolstr(ui, tool, "regappend", ""))
if p:
return p
exe = _toolstr(ui, tool, "executable", tool)
- return util.findexe(util.expandpath(exe))
+ return procutil.findexe(util.expandpath(exe))
def _picktool(repo, ui, path, binary, symlink, changedelete):
def supportscd(tool):
@@ -149,7 +150,7 @@
# the nomerge tools are the only tools that support change/delete
# conflicts
pass
- elif not util.gui() and _toolbool(ui, tool, "gui"):
+ elif not procutil.gui() and _toolbool(ui, tool, "gui"):
ui.warn(_("tool %s requires a GUI\n") % tmsg)
else:
return True
@@ -164,7 +165,7 @@
return ":prompt", None
else:
if toolpath:
- return (force, util.shellquote(toolpath))
+ return (force, procutil.shellquote(toolpath))
else:
# mimic HGMERGE if given tool not found
return (force, force)
@@ -182,7 +183,7 @@
mf = match.match(repo.root, '', [pat])
if mf(path) and check(tool, pat, symlink, False, changedelete):
toolpath = _findtool(ui, tool)
- return (tool, util.shellquote(toolpath))
+ return (tool, procutil.shellquote(toolpath))
# then merge tools
tools = {}
@@ -207,7 +208,7 @@
for p, t in tools:
if check(t, None, symlink, binary, changedelete):
toolpath = _findtool(ui, t)
- return (t, util.shellquote(toolpath))
+ return (t, procutil.shellquote(toolpath))
# internal merge or prompt as last resort
if symlink or binary or changedelete:
@@ -547,8 +548,9 @@
replace = {'local': localpath, 'base': basepath, 'other': otherpath,
'output': outpath, 'labellocal': mylabel,
'labelother': otherlabel, 'labelbase': baselabel}
- args = util.interpolate(br'\$', replace, args,
- lambda s: util.shellquote(util.localpath(s)))
+ args = util.interpolate(
+ br'\$', replace, args,
+ lambda s: procutil.shellquote(util.localpath(s)))
cmd = toolpath + ' ' + args
if _toolbool(ui, tool, "gui"):
repo.ui.status(_('running merge tool %s for file %s\n') %
--- a/mercurial/hgweb/__init__.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/hgweb/__init__.py Sat Mar 24 15:10:51 2018 +0900
@@ -15,7 +15,10 @@
from .. import (
error,
pycompat,
- util,
+)
+
+from ..utils import (
+ procutil,
)
from . import (
@@ -51,7 +54,7 @@
self.opts = opts
def init(self):
- util.setsignalhandler()
+ procutil.setsignalhandler()
self.httpd = server.create_server(self.ui, self.app)
if self.opts['port'] and not self.ui.verbose:
--- a/mercurial/hgweb/wsgicgi.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/hgweb/wsgicgi.py Sat Mar 24 15:10:51 2018 +0900
@@ -12,7 +12,6 @@
from .. import (
encoding,
- util,
)
from ..utils import (
@@ -24,8 +23,8 @@
)
def launch(application):
- util.setbinary(procutil.stdin)
- util.setbinary(procutil.stdout)
+ procutil.setbinary(procutil.stdin)
+ procutil.setbinary(procutil.stdout)
environ = dict(encoding.environ.iteritems())
environ.setdefault(r'PATH_INFO', '')
--- a/mercurial/hook.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/hook.py Sat Mar 24 15:10:51 2018 +0900
@@ -44,7 +44,7 @@
% (hname, funcname))
modname = funcname[:d]
oldpaths = sys.path
- if util.mainfrozen():
+ if procutil.mainfrozen():
# binary installs require sys.path manipulation
modpath, modfile = os.path.split(modname)
if modpath and modfile:
@@ -154,7 +154,7 @@
ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
name, cmd, duration)
if r:
- desc, r = util.explainexit(r)
+ desc, r = procutil.explainexit(r)
if throw:
raise error.HookAbort(_('%s hook %s') % (name, desc))
ui.warn(_('warning: %s hook %s\n') % (name, desc))
--- a/mercurial/localrepo.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/localrepo.py Sat Mar 24 15:10:51 2018 +0900
@@ -65,6 +65,7 @@
vfs as vfsmod,
)
from .utils import (
+ procutil,
stringutil,
)
@@ -1106,7 +1107,7 @@
params = cmd[len(name):].lstrip()
break
if not fn:
- fn = lambda s, c, **kwargs: util.filter(s, c)
+ fn = lambda s, c, **kwargs: procutil.filter(s, c)
# Wrap old filters not supporting keyword arguments
if not pycompat.getargspec(fn)[2]:
oldfn = fn
--- a/mercurial/lock.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/lock.py Sat Mar 24 15:10:51 2018 +0900
@@ -21,7 +21,10 @@
encoding,
error,
pycompat,
- util,
+)
+
+from .utils import (
+ procutil,
)
def _getlockprefix():
@@ -212,8 +215,8 @@
self.release()
def _getpid(self):
- # wrapper around util.getpid() to make testing easier
- return util.getpid()
+ # wrapper around procutil.getpid() to make testing easier
+ return procutil.getpid()
def lock(self):
timeout = self.timeout
@@ -299,7 +302,7 @@
pid = int(pid)
except ValueError:
return locker
- if util.testpid(pid):
+ if procutil.testpid(pid):
return locker
# if locker dead, break lock. must do this with another lock
# held, or can race and break valid lock.
--- a/mercurial/mail.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/mail.py Sat Mar 24 15:10:51 2018 +0900
@@ -25,6 +25,7 @@
util,
)
from .utils import (
+ procutil,
stringutil,
)
@@ -143,13 +144,13 @@
cmdline = '%s -f %s %s' % (program, stringutil.email(sender),
' '.join(map(stringutil.email, recipients)))
ui.note(_('sending mail: %s\n') % cmdline)
- fp = util.popen(cmdline, 'w')
+ fp = procutil.popen(cmdline, 'w')
fp.write(msg)
ret = fp.close()
if ret:
raise error.Abort('%s %s' % (
os.path.basename(program.split(None, 1)[0]),
- util.explainexit(ret)[0]))
+ procutil.explainexit(ret)[0]))
def _mbox(mbox, sender, recipients, msg):
'''write mails to mbox'''
@@ -184,7 +185,7 @@
raise error.Abort(_('smtp specified as email transport, '
'but no smtp host configured'))
else:
- if not util.findexe(method):
+ if not procutil.findexe(method):
raise error.Abort(_('%r specified as email transport, '
'but not in PATH') % method)
--- a/mercurial/patch.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/patch.py Sat Mar 24 15:10:51 2018 +0900
@@ -42,6 +42,7 @@
)
from .utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -2100,9 +2101,9 @@
args = []
cwd = repo.root
if cwd:
- args.append('-d %s' % util.shellquote(cwd))
- fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
- util.shellquote(patchname)))
+ args.append('-d %s' % procutil.shellquote(cwd))
+ fp = procutil.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
+ procutil.shellquote(patchname)))
try:
for line in util.iterfile(fp):
line = line.rstrip()
@@ -2130,7 +2131,7 @@
code = fp.close()
if code:
raise PatchError(_("patch command failed: %s") %
- util.explainexit(code)[0])
+ procutil.explainexit(code)[0])
return fuzz
def patchbackend(ui, backend, patchobj, strip, prefix, files=None,
--- a/mercurial/scmutil.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/scmutil.py Sat Mar 24 15:10:51 2018 +0900
@@ -42,6 +42,7 @@
)
from .utils import (
+ procutil,
stringutil,
)
@@ -293,7 +294,7 @@
if abort or warn:
msg = util.checkwinfilename(f)
if msg:
- msg = "%s: %s" % (msg, util.shellquote(f))
+ msg = "%s: %s" % (msg, procutil.shellquote(f))
if abort:
raise error.Abort(msg)
ui.warn(_("warning: %s\n") % msg)
@@ -1090,7 +1091,7 @@
# external commands should be run relative to the repo root
cmd = spec[6:]
proc = subprocess.Popen(cmd, shell=True, bufsize=-1,
- close_fds=util.closefds,
+ close_fds=procutil.closefds,
stdout=subprocess.PIPE, cwd=repo.root)
src = proc.stdout
else:
@@ -1114,7 +1115,7 @@
src.close()
if proc and proc.returncode != 0:
raise error.Abort(_("extdata command '%s' failed: %s")
- % (cmd, util.explainexit(proc.returncode)[0]))
+ % (cmd, procutil.explainexit(proc.returncode)[0]))
return data
--- a/mercurial/server.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/server.py Sat Mar 24 15:10:51 2018 +0900
@@ -46,7 +46,7 @@
os.close(lockfd)
try:
if not runargs:
- runargs = util.hgcmd() + pycompat.sysargv[1:]
+ runargs = procutil.hgcmd() + pycompat.sysargv[1:]
runargs.append('--daemon-postexec=unlink:%s' % lockpath)
# Don't pass --cwd to the child process, because we've already
# changed directory.
@@ -59,7 +59,7 @@
break
def condfn():
return not os.path.exists(lockpath)
- pid = util.rundetached(runargs, condfn)
+ pid = procutil.rundetached(runargs, condfn)
if pid < 0:
raise error.Abort(_('child process failed to start'))
writepid(pid)
@@ -74,7 +74,7 @@
initfn()
if not opts['daemon']:
- writepid(util.getpid())
+ writepid(procutil.getpid())
if opts['daemon_postexec']:
try:
@@ -90,7 +90,7 @@
elif inst != 'none':
raise error.Abort(_('invalid value for --daemon-postexec: %s')
% inst)
- util.hidewindow()
+ procutil.hidewindow()
procutil.stdout.flush()
procutil.stderr.flush()
--- a/mercurial/sshpeer.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/sshpeer.py Sat Mar 24 15:10:51 2018 +0900
@@ -19,6 +19,9 @@
wireprotoserver,
wireprototypes,
)
+from .utils import (
+ procutil,
+)
def _serverquote(s):
"""quote a string for the remote shell ... which we assume is sh"""
@@ -33,7 +36,7 @@
This is non blocking."""
if pipe:
- s = util.readpipe(pipe)
+ s = procutil.readpipe(pipe)
if s:
for l in s.splitlines():
ui.status(_("remote: "), l, '\n')
@@ -147,16 +150,16 @@
cmd = '%s %s %s' % (
sshcmd,
args,
- util.shellquote('%s -R %s serve --stdio' % (
+ procutil.shellquote('%s -R %s serve --stdio' % (
_serverquote(remotecmd), _serverquote(path))))
ui.debug('running %s\n' % cmd)
- cmd = util.quotecommand(cmd)
+ cmd = procutil.quotecommand(cmd)
# no buffer allow the use of 'select'
# feel free to remove buffering and select usage when we ultimately
# move to threading.
- stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv)
+ stdin, stdout, stderr, proc = procutil.popen4(cmd, bufsize=0, env=sshenv)
return proc, stdin, stdout, stderr
@@ -593,14 +596,14 @@
sshcmd = ui.config('ui', 'ssh')
remotecmd = ui.config('ui', 'remotecmd')
sshaddenv = dict(ui.configitems('sshenv'))
- sshenv = util.shellenviron(sshaddenv)
+ sshenv = procutil.shellenviron(sshaddenv)
remotepath = u.path or '.'
- args = util.sshargs(sshcmd, u.host, u.user, u.port)
+ args = procutil.sshargs(sshcmd, u.host, u.user, u.port)
if create:
cmd = '%s %s %s' % (sshcmd, args,
- util.shellquote('%s init %s' %
+ procutil.shellquote('%s init %s' %
(_serverquote(remotecmd), _serverquote(remotepath))))
ui.debug('running %s\n' % cmd)
res = ui.system(cmd, blockedtag='sshpeer', environ=sshenv)
--- a/mercurial/sslutil.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/sslutil.py Sat Mar 24 15:10:51 2018 +0900
@@ -22,6 +22,7 @@
util,
)
from .utils import (
+ procutil,
stringutil,
)
@@ -686,7 +687,7 @@
for using system certificate store CAs in addition to the provided
cacerts file
"""
- if (not pycompat.isdarwin or util.mainfrozen() or
+ if (not pycompat.isdarwin or procutil.mainfrozen() or
not pycompat.sysexecutable):
return False
exe = os.path.realpath(pycompat.sysexecutable).lower()
--- a/mercurial/subrepo.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/subrepo.py Sat Mar 24 15:10:51 2018 +0900
@@ -38,6 +38,7 @@
)
from .utils import (
dateutil,
+ procutil,
stringutil,
)
@@ -912,7 +913,7 @@
def __init__(self, ctx, path, state, allowcreate):
super(svnsubrepo, self).__init__(ctx, path)
self._state = state
- self._exe = util.findexe('svn')
+ self._exe = procutil.findexe('svn')
if not self._exe:
raise error.Abort(_("'svn' executable not found for subrepo '%s'")
% self._path)
@@ -942,7 +943,7 @@
env['LANG'] = lc_all
del env['LC_ALL']
env['LC_MESSAGES'] = 'C'
- p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds,
+ p = subprocess.Popen(cmd, bufsize=-1, close_fds=procutil.closefds,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, env=env, **extrakw)
stdout, stderr = p.communicate()
@@ -1260,7 +1261,7 @@
# the end of git diff arguments is used for paths
commands.insert(1, '--color')
p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1,
- cwd=cwd, env=env, close_fds=util.closefds,
+ cwd=cwd, env=env, close_fds=procutil.closefds,
stdout=subprocess.PIPE, stderr=errpipe)
if stream:
return p.stdout, None
--- a/mercurial/ui.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/ui.py Sat Mar 24 15:10:51 2018 +0900
@@ -808,7 +808,7 @@
user = self.prompt(_("enter a commit username:"), default=None)
if user is None and not self.interactive():
try:
- user = '%s@%s' % (util.getuser(),
+ user = '%s@%s' % (procutil.getuser(),
encoding.strtolocal(socket.getfqdn()))
self.warn(_("no username found, using '%s' instead\n") % user)
except KeyError:
@@ -992,7 +992,7 @@
def _isatty(self, fh):
if self.configbool('ui', 'nontty'):
return False
- return util.isatty(fh)
+ return procutil.isatty(fh)
def disablepager(self):
self._disablepager = True
@@ -1088,7 +1088,7 @@
# user so we can also get sane bad PAGER behavior. MSYS has
# `more.exe`, so do a cmd.exe style resolution of the executable to
# determine which one to use.
- fullcmd = util.findexe(command)
+ fullcmd = procutil.findexe(command)
if not fullcmd:
self.warn(_("missing pager command '%s', skipping pager\n")
% command)
@@ -1099,9 +1099,9 @@
try:
pager = subprocess.Popen(
command, shell=shell, bufsize=-1,
- close_fds=util.closefds, stdin=subprocess.PIPE,
+ close_fds=procutil.closefds, stdin=subprocess.PIPE,
stdout=procutil.stdout, stderr=procutil.stderr,
- env=util.shellenviron(env))
+ env=procutil.shellenviron(env))
except OSError as e:
if e.errno == errno.ENOENT and not shell:
self.warn(_("missing pager command '%s', skipping pager\n")
@@ -1277,7 +1277,8 @@
# we use rawinput() only if call_readline() will be invoked by
# PyOS_Readline(), so no I/O will be made at Python layer.
usereadline = (self._isatty(self.fin) and self._isatty(self.fout)
- and util.isstdin(self.fin) and util.isstdout(self.fout))
+ and procutil.isstdin(self.fin)
+ and procutil.isstdout(self.fout))
if usereadline:
try:
# magically add command line editing support, where
@@ -1504,7 +1505,7 @@
rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out)
if rc and onerr:
errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
- util.explainexit(rc)[0])
+ procutil.explainexit(rc)[0])
if errprefix:
errmsg = '%s: %s' % (errprefix, errmsg)
raise onerr(errmsg)
@@ -1513,7 +1514,7 @@
def _runsystem(self, cmd, environ, cwd, out):
"""actually execute the given shell command (can be overridden by
extensions like chg)"""
- return util.system(cmd, environ=environ, cwd=cwd, out=out)
+ return procutil.system(cmd, environ=environ, cwd=cwd, out=out)
def traceback(self, exc=None, force=False):
'''print exception traceback if traceback printing enabled or forced.
--- a/mercurial/wireprotoserver.py Sat Mar 24 15:09:33 2018 +0900
+++ b/mercurial/wireprotoserver.py Sat Mar 24 15:10:51 2018 +0900
@@ -22,6 +22,9 @@
wireprotoframing,
wireprototypes,
)
+from .utils import (
+ procutil,
+)
stringio = util.stringio
@@ -1030,8 +1033,8 @@
ui.fout = repo.ui.fout = ui.ferr
# Prevent insertion/deletion of CRs
- util.setbinary(self._fin)
- util.setbinary(self._fout)
+ procutil.setbinary(self._fin)
+ procutil.setbinary(self._fout)
def serve_forever(self):
self.serveuntil(threading.Event())
--- a/tests/mockblackbox.py Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/mockblackbox.py Sat Mar 24 15:10:51 2018 +0900
@@ -1,6 +1,6 @@
from __future__ import absolute_import
-from mercurial import (
- util,
+from mercurial.utils import (
+ procutil,
)
# XXX: we should probably offer a devel option to do this in blackbox directly
@@ -11,5 +11,5 @@
# mock the date and user apis so the output is always the same
def uisetup(ui):
- util.getuser = getuser
- util.getpid = getpid
+ procutil.getuser = getuser
+ procutil.getpid = getpid
--- a/tests/test-acl.t Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/test-acl.t Sat Mar 24 15:10:51 2018 +0900
@@ -23,11 +23,12 @@
> cat > posixgetuser.py <<'EOF'
> import getpass
- > from mercurial import pycompat, util
+ > from mercurial import pycompat
+ > from mercurial.utils import procutil
> def posixgetuser():
> return pycompat.fsencode(getpass.getuser())
> if not pycompat.isposix:
- > util.getuser = posixgetuser # forcibly trust $LOGNAME
+ > procutil.getuser = posixgetuser # forcibly trust $LOGNAME
> EOF
> init_config()
--- a/tests/test-annotate.t Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/test-annotate.t Sat Mar 24 15:10:51 2018 +0900
@@ -910,9 +910,9 @@
$ cat <<'EOF' >> "$TESTTMP/substcr.py"
> import sys
- > from mercurial import util
- > util.setbinary(sys.stdin)
- > util.setbinary(sys.stdout)
+ > from mercurial.utils import procutil
+ > procutil.setbinary(sys.stdin)
+ > procutil.setbinary(sys.stdout)
> stdin = getattr(sys.stdin, 'buffer', sys.stdin)
> stdout = getattr(sys.stdout, 'buffer', sys.stdout)
> stdout.write(stdin.read().replace(b'\r', b'[CR]'))
--- a/tests/test-journal-share.t Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/test-journal-share.t Sat Mar 24 15:10:51 2018 +0900
@@ -1,9 +1,10 @@
Journal extension test: tests the share extension support
$ cat >> testmocks.py << EOF
- > # mock out util.getuser() and util.makedate() to supply testable values
+ > # mock out procutil.getuser() and util.makedate() to supply testable values
> import os
> from mercurial import util
+ > from mercurial.utils import procutil
> def mockgetuser():
> return 'foobar'
>
@@ -18,7 +19,7 @@
> timef.write(str(time))
> return (time, 0)
>
- > util.getuser = mockgetuser
+ > procutil.getuser = mockgetuser
> util.makedate = mockmakedate
> EOF
--- a/tests/test-journal.t Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/test-journal.t Sat Mar 24 15:10:51 2018 +0900
@@ -1,10 +1,10 @@
Tests for the journal extension; records bookmark locations.
$ cat >> testmocks.py << EOF
- > # mock out util.getuser() and util.makedate() to supply testable values
+ > # mock out procutil.getuser() and util.makedate() to supply testable values
> import os
> from mercurial import util
- > from mercurial.utils import dateutil
+ > from mercurial.utils import dateutil, procutil
> def mockgetuser():
> return 'foobar'
>
@@ -19,7 +19,7 @@
> timef.write(str(time))
> return (time, 0)
>
- > util.getuser = mockgetuser
+ > procutil.getuser = mockgetuser
> dateutil.makedate = mockmakedate
> EOF
--- a/tests/test-sshserver.py Sat Mar 24 15:09:33 2018 +0900
+++ b/tests/test-sshserver.py Sat Mar 24 15:10:51 2018 +0900
@@ -6,11 +6,14 @@
import silenttestrunner
from mercurial import (
- util,
wireproto,
wireprotoserver,
)
+from mercurial.utils import (
+ procutil,
+)
+
class SSHServerGetArgsTests(unittest.TestCase):
def testparseknown(self):
tests = [
@@ -46,5 +49,5 @@
if __name__ == '__main__':
# Don't call into msvcrt to set BytesIO to binary mode
- util.setbinary = lambda fp: True
+ procutil.setbinary = lambda fp: True
silenttestrunner.main(__name__)