comparison mercurial/dispatch.py @ 36641:77f98867538f

py3: fix some unicode madness in global exception catcher
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 10:02:36 -0500
parents e8c361316803
children 68328202f270
comparison
equal deleted inserted replaced
36640:c77c925987d7 36641:77f98867538f
494 494
495 try: 495 try:
496 args = pycompat.shlexsplit(self.definition) 496 args = pycompat.shlexsplit(self.definition)
497 except ValueError as inst: 497 except ValueError as inst:
498 self.badalias = (_("error in definition for alias '%s': %s") 498 self.badalias = (_("error in definition for alias '%s': %s")
499 % (self.name, inst)) 499 % (self.name, util.forcebytestr(inst)))
500 return 500 return
501 earlyopts, args = _earlysplitopts(args) 501 earlyopts, args = _earlysplitopts(args)
502 if earlyopts: 502 if earlyopts:
503 self.badalias = (_("error in definition for alias '%s': %s may " 503 self.badalias = (_("error in definition for alias '%s': %s may "
504 "only be given on the command line") 504 "only be given on the command line")
621 cmdoptions = {} 621 cmdoptions = {}
622 622
623 try: 623 try:
624 args = fancyopts.fancyopts(args, commands.globalopts, options) 624 args = fancyopts.fancyopts(args, commands.globalopts, options)
625 except getopt.GetoptError as inst: 625 except getopt.GetoptError as inst:
626 raise error.CommandError(None, inst) 626 raise error.CommandError(None, util.forcebytestr(inst))
627 627
628 if args: 628 if args:
629 cmd, args = args[0], args[1:] 629 cmd, args = args[0], args[1:]
630 aliases, entry = cmdutil.findcmd(cmd, commands.table, 630 aliases, entry = cmdutil.findcmd(cmd, commands.table,
631 ui.configbool("ui", "strict")) 631 ui.configbool("ui", "strict"))
645 c.append((o[0], o[1], options[o[1]], o[3])) 645 c.append((o[0], o[1], options[o[1]], o[3]))
646 646
647 try: 647 try:
648 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True) 648 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
649 except getopt.GetoptError as inst: 649 except getopt.GetoptError as inst:
650 raise error.CommandError(cmd, inst) 650 raise error.CommandError(cmd, util.forcebytestr(inst))
651 651
652 # separate global options back out 652 # separate global options back out
653 for o in commands.globalopts: 653 for o in commands.globalopts:
654 n = o[1] 654 n = o[1]
655 options[n] = cmdoptions[n] 655 options[n] = cmdoptions[n]
670 raise IndexError 670 raise IndexError
671 ui.setconfig(section, name, value, '--config') 671 ui.setconfig(section, name, value, '--config')
672 configs.append((section, name, value)) 672 configs.append((section, name, value))
673 except (IndexError, ValueError): 673 except (IndexError, ValueError):
674 raise error.Abort(_('malformed --config option: %r ' 674 raise error.Abort(_('malformed --config option: %r '
675 '(use --config section.name=value)') % cfg) 675 '(use --config section.name=value)')
676 % pycompat.bytestr(cfg))
676 677
677 return configs 678 return configs
678 679
679 def _earlyparseopts(ui, args): 680 def _earlyparseopts(ui, args):
680 options = {} 681 options = {}