Show More
@@ -119,7 +119,7 b' def earlygetopt(args, shortlist, namelis' | |||||
119 | >>> get([b'--cwd=foo', b'x', b'y', b'-R', b'bar', b'--debugger'], gnu=False) |
|
119 | >>> get([b'--cwd=foo', b'x', b'y', b'-R', b'bar', b'--debugger'], gnu=False) | |
120 | ([('--cwd', 'foo')], ['x', 'y', '-R', 'bar', '--debugger']) |
|
120 | ([('--cwd', 'foo')], ['x', 'y', '-R', 'bar', '--debugger']) | |
121 | >>> get([b'--unknown', b'--cwd=foo', b'--', '--debugger'], gnu=False) |
|
121 | >>> get([b'--unknown', b'--cwd=foo', b'--', '--debugger'], gnu=False) | |
122 | ([], ['--unknown', '--cwd=foo', '--debugger']) |
|
122 | ([], ['--unknown', '--cwd=foo', '--', '--debugger']) | |
123 |
|
123 | |||
124 | stripping early options (without loosing '--'): |
|
124 | stripping early options (without loosing '--'): | |
125 |
|
125 | |||
@@ -141,6 +141,13 b' def earlygetopt(args, shortlist, namelis' | |||||
141 | >>> get([b'-q', b'--']) |
|
141 | >>> get([b'-q', b'--']) | |
142 | ([('-q', '')], []) |
|
142 | ([('-q', '')], []) | |
143 |
|
143 | |||
|
144 | '--' may be a value: | |||
|
145 | ||||
|
146 | >>> get([b'-R', b'--', b'x']) | |||
|
147 | ([('-R', '--')], ['x']) | |||
|
148 | >>> get([b'--cwd', b'--', b'x']) | |||
|
149 | ([('--cwd', '--')], ['x']) | |||
|
150 | ||||
144 | value passed to bool options: |
|
151 | value passed to bool options: | |
145 |
|
152 | |||
146 | >>> get([b'--debugger=foo', b'x']) |
|
153 | >>> get([b'--debugger=foo', b'x']) | |
@@ -163,20 +170,16 b' def earlygetopt(args, shortlist, namelis' | |||||
163 | >>> get([b'-', b'y']) |
|
170 | >>> get([b'-', b'y']) | |
164 | ([], ['-', 'y']) |
|
171 | ([], ['-', 'y']) | |
165 | """ |
|
172 | """ | |
166 | # ignoring everything just after '--' isn't correct as '--' may be an |
|
|||
167 | # option value (e.g. ['-R', '--']), but we do that consistently. |
|
|||
168 | try: |
|
|||
169 | argcount = args.index('--') |
|
|||
170 | except ValueError: |
|
|||
171 | argcount = len(args) |
|
|||
172 |
|
||||
173 | parsedopts = [] |
|
173 | parsedopts = [] | |
174 | parsedargs = [] |
|
174 | parsedargs = [] | |
175 | pos = 0 |
|
175 | pos = 0 | |
176 |
while pos < |
|
176 | while pos < len(args): | |
177 | arg = args[pos] |
|
177 | arg = args[pos] | |
|
178 | if arg == '--': | |||
|
179 | pos += not keepsep | |||
|
180 | break | |||
178 | flag, hasval, val, takeval = _earlyoptarg(arg, shortlist, namelist) |
|
181 | flag, hasval, val, takeval = _earlyoptarg(arg, shortlist, namelist) | |
179 |
if not hasval and takeval and pos + 1 >= |
|
182 | if not hasval and takeval and pos + 1 >= len(args): | |
180 | # missing last argument |
|
183 | # missing last argument | |
181 | break |
|
184 | break | |
182 | if not flag or hasval and not takeval: |
|
185 | if not flag or hasval and not takeval: | |
@@ -195,8 +198,7 b' def earlygetopt(args, shortlist, namelis' | |||||
195 | parsedopts.append((flag, args[pos + 1])) |
|
198 | parsedopts.append((flag, args[pos + 1])) | |
196 | pos += 2 |
|
199 | pos += 2 | |
197 |
|
200 | |||
198 |
parsedargs.extend(args[pos: |
|
201 | parsedargs.extend(args[pos:]) | |
199 | parsedargs.extend(args[argcount + (not keepsep):]) |
|
|||
200 | return parsedopts, parsedargs |
|
202 | return parsedopts, parsedargs | |
201 |
|
203 | |||
202 | def fancyopts(args, options, state, gnu=False, early=False, optaliases=None): |
|
204 | def fancyopts(args, options, state, gnu=False, early=False, optaliases=None): |
@@ -40,10 +40,10 b' Missing parameter for early option:' | |||||
40 | "--" may be an option value: |
|
40 | "--" may be an option value: | |
41 |
|
41 | |||
42 | $ hg -R -- log |
|
42 | $ hg -R -- log | |
43 | abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo! |
|
43 | abort: repository -- not found! | |
44 | [255] |
|
44 | [255] | |
45 | $ hg log -R -- |
|
45 | $ hg log -R -- | |
46 | abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo! |
|
46 | abort: repository -- not found! | |
47 | [255] |
|
47 | [255] | |
48 | $ hg log -T -- |
|
48 | $ hg log -T -- | |
49 | -- (no-eol) |
|
49 | -- (no-eol) |
General Comments 0
You need to be logged in to leave comments.
Login now