##// END OF EJS Templates
dispatch: alias --repo to --repository while parsing early options...
Yuya Nishihara -
r35223:4edd2202 default
parent child Browse files
Show More
@@ -649,7 +649,8 def _parseconfig(ui, config):
649 649 def _earlyparseopts(args):
650 650 options = {}
651 651 fancyopts.fancyopts(args, commands.globalopts, options,
652 gnu=False, early=True)
652 gnu=False, early=True,
653 optaliases={'repository': ['repo']})
653 654 return options
654 655
655 656 def _earlygetopt(aliases, args, strip=True):
@@ -226,7 +226,7 def gnugetopt(args, options, longoptions
226 226 return opts, args
227 227
228 228
229 def fancyopts(args, options, state, gnu=False, early=False):
229 def fancyopts(args, options, state, gnu=False, early=False, optaliases=None):
230 230 """
231 231 read args, parse options, and store options in state
232 232
@@ -246,8 +246,15 def fancyopts(args, options, state, gnu=
246 246 integer - parameter strings is stored as int
247 247 function - call function with parameter
248 248
249 optaliases is a mapping from a canonical option name to a list of
250 additional long options. This exists for preserving backward compatibility
251 of early options. If we want to use it extensively, please consider moving
252 the functionality to the options table (e.g separate long options by '|'.)
253
249 254 non-option args are returned
250 255 """
256 if optaliases is None:
257 optaliases = {}
251 258 namelist = []
252 259 shortlist = ''
253 260 argmap = {}
@@ -261,10 +268,13 def fancyopts(args, options, state, gnu=
261 268 else:
262 269 short, name, default, comment = option
263 270 # convert opts to getopt format
264 oname = name
271 onames = [name]
272 onames.extend(optaliases.get(name, []))
265 273 name = name.replace('-', '_')
266 274
267 argmap['-' + short] = argmap['--' + oname] = name
275 argmap['-' + short] = name
276 for n in onames:
277 argmap['--' + n] = name
268 278 defmap[name] = default
269 279
270 280 # copy defaults to state
@@ -279,24 +289,24 def fancyopts(args, options, state, gnu=
279 289 if not (default is None or default is True or default is False):
280 290 if short:
281 291 short += ':'
282 if oname:
283 oname += '='
284 elif oname not in nevernegate:
285 if oname.startswith('no-'):
286 insert = oname[3:]
292 onames = [n + '=' for n in onames]
293 elif name not in nevernegate:
294 for n in onames:
295 if n.startswith('no-'):
296 insert = n[3:]
287 297 else:
288 insert = 'no-' + oname
298 insert = 'no-' + n
289 299 # backout (as a practical example) has both --commit and
290 300 # --no-commit options, so we don't want to allow the
291 301 # negations of those flags.
292 302 if insert not in alllong:
293 assert ('--' + oname) not in negations
294 negations['--' + insert] = '--' + oname
303 assert ('--' + n) not in negations
304 negations['--' + insert] = '--' + n
295 305 namelist.append(insert)
296 306 if short:
297 307 shortlist += short
298 308 if name:
299 namelist.append(oname)
309 namelist.extend(onames)
300 310
301 311 # parse arguments
302 312 if early:
@@ -150,6 +150,10 Early options must come first if HGPLAIN
150 150 [255]
151 151 $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default
152 152 0:cb9a9f314b8b
153 $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default
154 0:cb9a9f314b8b
155 $ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default
156 0:cb9a9f314b8b
153 157
154 158 For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN:
155 159
General Comments 0
You need to be logged in to leave comments. Login now