##// END OF EJS Templates
githelp: make argument parsing more compatible with Python 3...
Gregory Szorc -
r41459:031d9162 default
parent child Browse files
Show More
@@ -25,6 +25,7 b' from mercurial import ('
25 25 encoding,
26 26 error,
27 27 fancyopts,
28 pycompat,
28 29 registrar,
29 30 scmutil,
30 31 )
@@ -83,20 +84,22 b' def parseoptions(ui, cmdoptions, args):'
83 84 args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
84 85 break
85 86 except getopt.GetoptError as ex:
86 if "requires argument" in ex.msg:
87 if r"requires argument" in ex.msg:
87 88 raise
88 if ('--' + ex.opt) in ex.msg:
89 flag = '--' + ex.opt
90 elif ('-' + ex.opt) in ex.msg:
91 flag = '-' + ex.opt
89 if (r'--' + ex.opt) in ex.msg:
90 flag = '--' + pycompat.bytestr(ex.opt)
91 elif (r'-' + ex.opt) in ex.msg:
92 flag = '-' + pycompat.bytestr(ex.opt)
92 93 else:
93 raise error.Abort(_("unknown option %s") % ex.opt)
94 raise error.Abort(_("unknown option %s") %
95 pycompat.bytestr(ex.opt))
94 96 try:
95 97 args.remove(flag)
96 98 except Exception:
97 99 msg = _("unknown option '%s' packed with other options")
98 100 hint = _("please try passing the option as its own flag: -%s")
99 raise error.Abort(msg % ex.opt, hint=hint % ex.opt)
101 raise error.Abort(msg % pycompat.bytestr(ex.opt),
102 hint=hint % pycompat.bytestr(ex.opt))
100 103
101 104 ui.warn(_("ignoring unknown option %s\n") % flag)
102 105
General Comments 0
You need to be logged in to leave comments. Login now