comparison mercurial/dispatch.py @ 37084:f0b6fbea00cf

stringutil: bulk-replace call sites to point to new module This might conflict with other patches floating around, sorry.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 22 Mar 2018 21:56:20 +0900
parents 389b950f5190
children d4a2e0d5d042
comparison
equal deleted inserted replaced
37083:f99d64e8a4e4 37084:f0b6fbea00cf
37 pycompat, 37 pycompat,
38 registrar, 38 registrar,
39 scmutil, 39 scmutil,
40 ui as uimod, 40 ui as uimod,
41 util, 41 util,
42 )
43
44 from .utils import (
45 stringutil,
42 ) 46 )
43 47
44 unrecoverablewrite = registrar.command.unrecoverablewrite 48 unrecoverablewrite = registrar.command.unrecoverablewrite
45 49
46 class request(object): 50 class request(object):
494 498
495 try: 499 try:
496 args = pycompat.shlexsplit(self.definition) 500 args = pycompat.shlexsplit(self.definition)
497 except ValueError as inst: 501 except ValueError as inst:
498 self.badalias = (_("error in definition for alias '%s': %s") 502 self.badalias = (_("error in definition for alias '%s': %s")
499 % (self.name, util.forcebytestr(inst))) 503 % (self.name, stringutil.forcebytestr(inst)))
500 return 504 return
501 earlyopts, args = _earlysplitopts(args) 505 earlyopts, args = _earlysplitopts(args)
502 if earlyopts: 506 if earlyopts:
503 self.badalias = (_("error in definition for alias '%s': %s may " 507 self.badalias = (_("error in definition for alias '%s': %s may "
504 "only be given on the command line") 508 "only be given on the command line")
621 cmdoptions = {} 625 cmdoptions = {}
622 626
623 try: 627 try:
624 args = fancyopts.fancyopts(args, commands.globalopts, options) 628 args = fancyopts.fancyopts(args, commands.globalopts, options)
625 except getopt.GetoptError as inst: 629 except getopt.GetoptError as inst:
626 raise error.CommandError(None, util.forcebytestr(inst)) 630 raise error.CommandError(None, stringutil.forcebytestr(inst))
627 631
628 if args: 632 if args:
629 cmd, args = args[0], args[1:] 633 cmd, args = args[0], args[1:]
630 aliases, entry = cmdutil.findcmd(cmd, commands.table, 634 aliases, entry = cmdutil.findcmd(cmd, commands.table,
631 ui.configbool("ui", "strict")) 635 ui.configbool("ui", "strict"))
645 c.append((o[0], o[1], options[o[1]], o[3])) 649 c.append((o[0], o[1], options[o[1]], o[3]))
646 650
647 try: 651 try:
648 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True) 652 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
649 except getopt.GetoptError as inst: 653 except getopt.GetoptError as inst:
650 raise error.CommandError(cmd, util.forcebytestr(inst)) 654 raise error.CommandError(cmd, stringutil.forcebytestr(inst))
651 655
652 # separate global options back out 656 # separate global options back out
653 for o in commands.globalopts: 657 for o in commands.globalopts:
654 n = o[1] 658 n = o[1]
655 options[n] = cmdoptions[n] 659 options[n] = cmdoptions[n]
870 for ui_ in uis: 874 for ui_ in uis:
871 if coloropt: 875 if coloropt:
872 ui_.setconfig('ui', 'color', coloropt, '--color') 876 ui_.setconfig('ui', 'color', coloropt, '--color')
873 color.setup(ui_) 877 color.setup(ui_)
874 878
875 if util.parsebool(options['pager']): 879 if stringutil.parsebool(options['pager']):
876 # ui.pager() expects 'internal-always-' prefix in this case 880 # ui.pager() expects 'internal-always-' prefix in this case
877 ui.pager('internal-always-' + cmd) 881 ui.pager('internal-always-' + cmd)
878 elif options['pager'] != 'auto': 882 elif options['pager'] != 'auto':
879 for ui_ in uis: 883 for ui_ in uis:
880 ui_.disablepager() 884 ui_.disablepager()
966 worst = None, ct, '' 970 worst = None, ct, ''
967 if ui.config('ui', 'supportcontact') is None: 971 if ui.config('ui', 'supportcontact') is None:
968 for name, mod in extensions.extensions(): 972 for name, mod in extensions.extensions():
969 # 'testedwith' should be bytes, but not all extensions are ported 973 # 'testedwith' should be bytes, but not all extensions are ported
970 # to py3 and we don't want UnicodeException because of that. 974 # to py3 and we don't want UnicodeException because of that.
971 testedwith = util.forcebytestr(getattr(mod, 'testedwith', '')) 975 testedwith = stringutil.forcebytestr(getattr(mod, 'testedwith', ''))
972 report = getattr(mod, 'buglink', _('the extension author.')) 976 report = getattr(mod, 'buglink', _('the extension author.'))
973 if not testedwith.strip(): 977 if not testedwith.strip():
974 # We found an untested extension. It's likely the culprit. 978 # We found an untested extension. It's likely the culprit.
975 worst = name, 'unknown', report 979 worst = name, 'unknown', report
976 break 980 break
988 if worst[0] is None or nearest < worst[1]: 992 if worst[0] is None or nearest < worst[1]:
989 worst = name, nearest, report 993 worst = name, nearest, report
990 if worst[0] is not None: 994 if worst[0] is not None:
991 name, testedwith, report = worst 995 name, testedwith, report = worst
992 if not isinstance(testedwith, (bytes, str)): 996 if not isinstance(testedwith, (bytes, str)):
993 testedwith = '.'.join([util.forcebytestr(c) for c in testedwith]) 997 testedwith = '.'.join([stringutil.forcebytestr(c)
998 for c in testedwith])
994 warning = (_('** Unknown exception encountered with ' 999 warning = (_('** Unknown exception encountered with '
995 'possibly-broken third-party extension %s\n' 1000 'possibly-broken third-party extension %s\n'
996 '** which supports versions %s of Mercurial.\n' 1001 '** which supports versions %s of Mercurial.\n'
997 '** Please disable %s and try your action again.\n' 1002 '** Please disable %s and try your action again.\n'
998 '** If that fixes the bug please report it to %s\n') 1003 '** If that fixes the bug please report it to %s\n')