##// END OF EJS Templates
dispatch: abort if early boolean options can't be parsed...
Yuya Nishihara -
r35059:d9aba373 stable
parent child Browse files
Show More
@@ -55,6 +55,9 b' class request(object):'
55 self.fout = fout
55 self.fout = fout
56 self.ferr = ferr
56 self.ferr = ferr
57
57
58 # remember options pre-parsed by _earlyreqopt*()
59 self.earlyoptions = {}
60
58 # reposetups which run before extensions, useful for chg to pre-fill
61 # reposetups which run before extensions, useful for chg to pre-fill
59 # low-level repo state (for example, changelog) before extensions.
62 # low-level repo state (for example, changelog) before extensions.
60 self.prereposetups = prereposetups or []
63 self.prereposetups = prereposetups or []
@@ -707,19 +710,19 b' def _earlyreqoptbool(req, name, aliases)'
707
710
708 >>> req = request([b'x', b'--', b'--debugger'])
711 >>> req = request([b'x', b'--', b'--debugger'])
709 >>> _earlyreqoptbool(req, b'debugger', [b'--debugger'])
712 >>> _earlyreqoptbool(req, b'debugger', [b'--debugger'])
710 False
711 """
713 """
712 try:
714 try:
713 argcount = req.args.index("--")
715 argcount = req.args.index("--")
714 except ValueError:
716 except ValueError:
715 argcount = len(req.args)
717 argcount = len(req.args)
716 value = False
718 value = None
717 pos = 0
719 pos = 0
718 while pos < argcount:
720 while pos < argcount:
719 arg = req.args[pos]
721 arg = req.args[pos]
720 if arg in aliases:
722 if arg in aliases:
721 value = True
723 value = True
722 pos += 1
724 pos += 1
725 req.earlyoptions[name] = value
723 return value
726 return value
724
727
725 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
728 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
@@ -849,6 +852,9 b' def _dispatch(req):'
849 raise error.Abort(_(
852 raise error.Abort(_(
850 "option -R has to be separated from other options (e.g. not "
853 "option -R has to be separated from other options (e.g. not "
851 "-qR) and --repository may only be abbreviated as --repo!"))
854 "-qR) and --repository may only be abbreviated as --repo!"))
855 if options["debugger"] != req.earlyoptions["debugger"]:
856 raise error.Abort(_("option --debugger may not be abbreviated!"))
857 # don't validate --profile/--traceback, which can be enabled from now
852
858
853 if options["encoding"]:
859 if options["encoding"]:
854 encoding.encoding = options["encoding"]
860 encoding.encoding = options["encoding"]
@@ -51,6 +51,12 b' Parsing of early options should stop at '
51 --debugger: no such file in rev cb9a9f314b8b
51 --debugger: no such file in rev cb9a9f314b8b
52 [1]
52 [1]
53
53
54 Unparsable form of early options:
55
56 $ hg cat --debugg
57 abort: option --debugger may not be abbreviated!
58 [255]
59
54 [defaults]
60 [defaults]
55
61
56 $ hg cat a
62 $ hg cat a
General Comments 0
You need to be logged in to leave comments. Login now