Commit a9aedbb7 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

stringutil: bulk-replace call sites to point to new module

This might conflict with other patches floating around, sorry.
parent f99d64e8a4e4
......@@ -307,6 +307,9 @@ from mercurial import (
url,
util,
)
from mercurial.utils import (
stringutil,
)
xmlrpclib = util.xmlrpclib
......@@ -1099,7 +1102,8 @@ class bugzilla(object):
root=self.repo.root,
webroot=webroot(self.repo.root))
data = self.ui.popbuffer()
self.bzdriver.updatebug(bugid, newstate, data, util.email(ctx.user()))
self.bzdriver.updatebug(bugid, newstate, data,
stringutil.email(ctx.user()))
def notify(self, bugs, committer):
'''ensure Bugzilla users are notified of bug change.'''
......@@ -1119,6 +1123,6 @@ def hook(ui, repo, hooktype, node=None, **kwargs):
if bugs:
for bug in bugs:
bz.update(bug, bugs[bug], ctx)
bz.notify(bugs, util.email(ctx.user()))
bz.notify(bugs, stringutil.email(ctx.user()))
except Exception as e:
raise error.Abort(_('Bugzilla error: %s') % e)
......@@ -17,7 +17,10 @@ from mercurial import (
pycompat,
util,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
pickle = util.pickle
......@@ -452,7 +455,8 @@ def createlog(ui, directory=None, root="", rlog=True, cache=None):
rcsmap[e.rcs.replace('/Attic/', '/')] = e.rcs
if len(log) % 100 == 0:
ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n')
ui.status(stringutil.ellipsis('%d %s' % (len(log), e.file), 80)
+ '\n')
log.sort(key=lambda x: (x.rcs, x.revision))
......@@ -608,7 +612,7 @@ def createchangeset(ui, log, fuzz=60, mergefrom=None, mergeto=None):
files = set()
if len(changesets) % 100 == 0:
t = '%d %s' % (len(changesets), repr(e.comment)[1:-1])
ui.status(util.ellipsis(t, 80) + '\n')
ui.status(stringutil.ellipsis(t, 80) + '\n')
c.entries.append(e)
files.add(e.file)
......
......@@ -14,7 +14,10 @@ from mercurial import (
error,
util,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
from . import common
......@@ -169,7 +172,7 @@ class p4_source(common.converter_source):
shortdesc = '**empty changelist description**'
t = '%s %s' % (c.rev, repr(shortdesc)[1:-1])
ui.status(util.ellipsis(t, 80) + '\n')
ui.status(stringutil.ellipsis(t, 80) + '\n')
files = []
copies = {}
......
......@@ -16,7 +16,10 @@ from mercurial import (
util,
vfs as vfsmod,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
from . import common
......@@ -147,7 +150,7 @@ def get_log_child(fp, url, paths, start, end, limit=0,
# Caller may interrupt the iteration
pickle.dump(None, fp, protocol)
except Exception as inst:
pickle.dump(util.forcebytestr(inst), fp, protocol)
pickle.dump(stringutil.forcebytestr(inst), fp, protocol)
else:
pickle.dump(None, fp, protocol)
fp.flush()
......@@ -1315,7 +1318,7 @@ class svn_sink(converter_sink, commandline):
fp.close()
try:
output = self.run0('commit',
username=util.shortuser(commit.author),
username=stringutil.shortuser(commit.author),
file=messagefile,
encoding='utf-8')
try:
......
......@@ -105,6 +105,9 @@ from mercurial import (
registrar,
util,
)
from mercurial.utils import (
stringutil,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
......@@ -133,7 +136,7 @@ def inconsistenteol(data):
def tolf(s, params, ui, **kwargs):
"""Filter to convert to LF EOLs."""
if util.binary(s):
if stringutil.binary(s):
return s
if ui.configbool('eol', 'only-consistent') and inconsistenteol(s):
return s
......@@ -144,7 +147,7 @@ def tolf(s, params, ui, **kwargs):
def tocrlf(s, params, ui, **kwargs):
"""Filter to convert to CRLF EOLs."""
if util.binary(s):
if stringutil.binary(s):
return s
if ui.configbool('eol', 'only-consistent') and inconsistenteol(s):
return s
......@@ -403,7 +406,7 @@ def reposetup(ui, repo):
if fctx is None:
continue
data = fctx.data()
if util.binary(data):
if stringutil.binary(data):
# We should not abort here, since the user should
# be able to say "** = native" to automatically
# have all non-binary files taken care of.
......
......@@ -82,6 +82,9 @@ from mercurial import (
scmutil,
util,
)
from mercurial.utils import (
stringutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
......@@ -367,8 +370,8 @@ class savedcmd(object):
def __init__(self, path, cmdline):
# We can't pass non-ASCII through docstrings (and path is
# in an unknown encoding anyway)
docpath = util.escapestr(path)
self.__doc__ %= {r'path': pycompat.sysstr(util.uirepr(docpath))}
docpath = stringutil.escapestr(path)
self.__doc__ %= {r'path': pycompat.sysstr(stringutil.uirepr(docpath))}
self._cmdline = cmdline
def __call__(self, ui, repo, *pats, **opts):
......
......@@ -15,7 +15,10 @@ demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__'])
from mercurial import (
encoding,
util,
)
from mercurial.utils import (
stringutil,
)
with demandimport.deactivated():
......@@ -47,7 +50,7 @@ def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False):
tmpl.cache['header'] = new_header
text = fctx.data()
if util.binary(text):
if stringutil.binary(text):
return
# str.splitlines() != unicode.splitlines() because "reasons"
......
......@@ -209,6 +209,9 @@ from mercurial import (
scmutil,
util,
)
from mercurial.utils import (
stringutil,
)
pickle = util.pickle
release = lock.release
......@@ -465,7 +468,7 @@ class histeditaction(object):
# (the 5 more are left for verb)
maxlen = self.repo.ui.configint('histedit', 'linelen')
maxlen = max(maxlen, 22) # avoid truncating hash
return util.ellipsis(line, maxlen)
return stringutil.ellipsis(line, maxlen)
def tostate(self):
"""Print an action in format used by histedit state files
......
......@@ -36,7 +36,10 @@ from mercurial import (
registrar,
util,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
......@@ -376,9 +379,9 @@ class journalstorage(object):
"""
if namespace is not None:
namespace = util.stringmatcher(namespace)[-1]
namespace = stringutil.stringmatcher(namespace)[-1]
if name is not None:
name = util.stringmatcher(name)[-1]
name = stringutil.stringmatcher(name)[-1]
for entry in self:
if namespace is not None and not namespace(entry.namespace):
continue
......
......@@ -111,7 +111,10 @@ from mercurial import (
templatefilters,
util,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
......@@ -272,7 +275,8 @@ class kwtemplater(object):
def expand(self, path, node, data):
'''Returns data with keywords expanded.'''
if not self.restrict and self.match(path) and not util.binary(data):
if (not self.restrict and self.match(path)
and not stringutil.binary(data)):
ctx = self.linkctx(path, node)
return self.substitute(data, path, ctx, self.rekw.sub)
return data
......@@ -304,7 +308,7 @@ class kwtemplater(object):
data = self.repo.file(f).read(mf[f])
else:
data = self.repo.wread(f)
if util.binary(data):
if stringutil.binary(data):
continue
if expand:
parents = ctx.parents()
......@@ -335,7 +339,7 @@ class kwtemplater(object):
def shrink(self, fname, text):
'''Returns text with all keyword substitutions removed.'''
if self.match(fname) and not util.binary(text):
if self.match(fname) and not stringutil.binary(text):
return _shrinktext(text, self.rekwexp.sub)
return text
......@@ -343,7 +347,7 @@ class kwtemplater(object):
'''Returns lines with keyword substitutions removed.'''
if self.match(fname):
text = ''.join(lines)
if not util.binary(text):
if not stringutil.binary(text):
return _shrinktext(text, self.rekwexp.sub).splitlines(True)
return lines
......
......@@ -14,6 +14,10 @@ from mercurial import (
util,
)
from mercurial.utils import (
stringutil,
)
from . import (
basestore,
lfutil,
......@@ -52,7 +56,7 @@ class remotestore(basestore.basestore):
except IOError as e:
raise error.Abort(
_('remotestore: could not open file %s: %s')
% (filename, util.forcebytestr(e)))
% (filename, stringutil.forcebytestr(e)))
def _getfile(self, tmpfile, filename, hash):
try:
......@@ -61,7 +65,7 @@ class remotestore(basestore.basestore):
# 401s get converted to error.Aborts; everything else is fine being
# turned into a StoreError
raise basestore.StoreError(filename, hash, self.url,
util.forcebytestr(e))
stringutil.forcebytestr(e))
except urlerr.urlerror as e:
# This usually indicates a connection problem, so don't
# keep trying with the other files... they will probably
......@@ -70,7 +74,7 @@ class remotestore(basestore.basestore):
(util.hidepassword(self.url), e.reason))
except IOError as e:
raise basestore.StoreError(filename, hash, self.url,
util.forcebytestr(e))
stringutil.forcebytestr(e))
return lfutil.copyandhash(chunks, tmpfile)
......
......@@ -19,6 +19,10 @@ from mercurial import (
util,
)
from mercurial.utils import (
stringutil,
)
from ..largefiles import lfutil
from . import (
......@@ -95,7 +99,7 @@ def writetostore(self, text):
# by default, we expect the content to be binary. however, LFS could also
# be used for non-binary content. add a special entry for non-binary data.
# this will be used by filectx.isbinary().
if not util.binary(text):
if not stringutil.binary(text):
# not hg filelog metadata (affecting commit hash), no "x-hg-" prefix
metadata['x-is-binary'] = '0'
......
......@@ -98,7 +98,10 @@ from mercurial import (
util,
vfs as vfsmod,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
release = lockmod.release
seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
......@@ -469,7 +472,7 @@ class queue(object):
self.guardsdirty = False
# Handle mq.git as a bool with extended values
gitmode = ui.config('mq', 'git').lower()
boolmode = util.parsebool(gitmode)
boolmode = stringutil.parsebool(gitmode)
if boolmode is not None:
if boolmode:
gitmode = 'yes'
......@@ -724,7 +727,7 @@ class queue(object):
os.unlink(undo)
except OSError as inst:
self.ui.warn(_('error removing undo: %s\n') %
util.forcebytestr(inst))
stringutil.forcebytestr(inst))
def backup(self, repo, files, copy=False):
# backup local changes in --force case
......@@ -857,7 +860,7 @@ class queue(object):
files=files, eolmode=None)
return (True, list(files), fuzz)
except Exception as inst:
self.ui.note(util.forcebytestr(inst) + '\n')
self.ui.note(stringutil.forcebytestr(inst) + '\n')
if not self.ui.verbose:
self.ui.warn(_("patch failed, unable to continue (try -v)\n"))
self.ui.traceback()
......@@ -1917,7 +1920,7 @@ class queue(object):
if self.ui.formatted():
width = self.ui.termwidth() - len(pfx) - len(patchname) - 2
if width > 0:
msg = util.ellipsis(msg, width)
msg = stringutil.ellipsis(msg, width)
else:
msg = ''
self.ui.write(patchname, label='qseries.' + state)
......
......@@ -29,6 +29,9 @@ from mercurial import (
util,
wireproto,
)
from mercurial.utils import (
stringutil,
)
NARROWCAP = 'narrow'
_NARROWACL_SECTION = 'narrowhgacl'
......@@ -449,7 +452,7 @@ def handlechangegroup_widen(op, inpart):
except OSError as e:
if e.errno != errno.ENOENT:
ui.warn(_('error removing %s: %s\n') %
(undovfs.join(undofile), util.forcebytestr(e)))
(undovfs.join(undofile), stringutil.forcebytestr(e)))
# Remove partial backup only if there were no exceptions
vfs.unlink(chgrpfile)
......
......@@ -149,7 +149,10 @@ from mercurial import (
registrar,
util,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
......@@ -277,7 +280,7 @@ class notifier(object):
def fixmail(self, addr):
'''try to clean up email addresses.'''
addr = util.email(addr.strip())
addr = stringutil.email(addr.strip())
if self.domain:
a = addr.find('@localhost')
if a != -1:
......@@ -372,7 +375,7 @@ class notifier(object):
subject = '%s: %s' % (self.root, s)
maxsubject = int(self.ui.config('notify', 'maxsubject'))
if maxsubject:
subject = util.ellipsis(subject, maxsubject)
subject = stringutil.ellipsis(subject, maxsubject)
msg['Subject'] = mail.headencode(self.ui, subject,
self.charsets, self.test)
......@@ -399,7 +402,7 @@ class notifier(object):
else:
self.ui.status(_('notify: sending %d subscribers %d changes\n') %
(len(subs), count))
mail.sendmail(self.ui, util.email(msg['From']),
mail.sendmail(self.ui, stringutil.email(msg['From']),
subs, msgtext, mbox=self.mbox)
def diff(self, ctx, ref=None):
......
......@@ -18,6 +18,9 @@ from mercurial import (
registrar,
util,
)
from mercurial.utils import (
stringutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
......@@ -187,7 +190,7 @@ def do_relink(src, dst, files, ui):
relinked += 1
savedbytes += sz
except OSError as inst:
ui.warn('%s: %s\n' % (tgt, util.forcebytestr(inst)))
ui.warn('%s: %s\n' % (tgt, stringutil.forcebytestr(inst)))
ui.progress(_('relinking'), None)
......
......@@ -56,7 +56,10 @@ from mercurial import (
from . import (
rebase,
)
from mercurial.utils import dateutil
from mercurial.utils import (
dateutil,
stringutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
......@@ -477,7 +480,7 @@ def _docreatecmd(ui, repo, pats, opts):
_shelvecreatedcommit(repo, node, name)
if ui.formatted():
desc = util.ellipsis(desc, ui.termwidth())
desc = stringutil.ellipsis(desc, ui.termwidth())
ui.status(_('shelved as %s\n') % name)
hg.update(repo, parent.node())
if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
......@@ -578,7 +581,7 @@ def listcmd(ui, repo, pats, opts):
if not line.startswith('#'):
desc = line.rstrip()
if ui.formatted():
desc = util.ellipsis(desc, width - used)
desc = stringutil.ellipsis(desc, width - used)
ui.write(desc)
break
ui.write('\n')
......
......@@ -38,6 +38,9 @@ from mercurial import (
util,
vfs as vfsmod,
)
from mercurial.utils import (
stringutil,
)
class TransplantError(error.Abort):
pass
......@@ -311,7 +314,7 @@ class transplanter(object):
p1 = repo.dirstate.p1()
p2 = node
self.log(user, date, message, p1, p2, merge=merge)
self.ui.write(util.forcebytestr(inst) + '\n')
self.ui.write(stringutil.forcebytestr(inst) + '\n')
raise TransplantError(_('fix up the working directory and run '
'hg transplant --continue'))
else:
......
......@@ -50,7 +50,9 @@ from mercurial.node import (
)
from mercurial import (
registrar,
util,
)
from mercurial.utils import (
stringutil,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
......@@ -100,22 +102,22 @@ def macdumbencode(s, cmd):
return s.replace('\r', '\n')
def cleverdecode(s, cmd, **kwargs):
if not util.binary(s):
if not stringutil.binary(s):
return dumbdecode(s, cmd, **kwargs)
return s
def cleverencode(s, cmd):
if not util.binary(s):
if not stringutil.binary(s):
return dumbencode(s, cmd)
return s
def macdecode(s, cmd, **kwargs):
if not util.binary(s):
if not stringutil.binary(s):
return macdumbdecode(s, cmd, **kwargs)
return s
def macencode(s, cmd):
if not util.binary(s):
if not stringutil.binary(s):
return macdumbencode(s, cmd)
return s
......@@ -146,7 +148,7 @@ def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
continue
seen.add(f)
data = c[f].data()
if not util.binary(data) and newline in data:
if not stringutil.binary(data) and newline in data:
if not halt:
ui.warn(_('attempt to commit or push text file(s) '
'using %s line endings\n') %
......
......@@ -22,6 +22,9 @@ from . import (
scmutil,
util,
)
from .utils import (
stringutil,
)
calcsize = struct.calcsize
pack_into = struct.pack_into
......@@ -256,7 +259,7 @@ class branchcache(dict):
except (IOError, OSError, error.Abort) as inst:
# Abort may be raised by read only opener, so log and continue
repo.ui.debug("couldn't write branch cache: %s\n" %
util.forcebytestr(inst))
stringutil.forcebytestr(inst))
def update(self, repo, revgen):
"""Given a branchhead cache, self, that may have extra nodes or be
......@@ -378,7 +381,7 @@ class revbranchcache(object):
self._rbcrevs[:] = data
except (IOError, OSError) as inst:
repo.ui.debug("couldn't read revision branch cache: %s\n" %
util.forcebytestr(inst))
stringutil.forcebytestr(inst))
# remember number of good records on disk
self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize,
len(repo.changelog))
......@@ -540,7 +543,7 @@ class revbranchcache(object):
self._rbcrevslen = revs
except (IOError, OSError, error.Abort, error.LockError) as inst:
repo.ui.debug("couldn't write revision branch cache%s: %s\n"
% (step, util.forcebytestr(inst)))
% (step, stringutil.forcebytestr(inst)))
finally:
if wlock is not None:
wlock.release()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment