equal
deleted
inserted
replaced
385 option_lists = [] |
385 option_lists = [] |
386 if cmd and cmd != 'shortlist': |
386 if cmd and cmd != 'shortlist': |
387 if with_version: |
387 if with_version: |
388 show_version(ui) |
388 show_version(ui) |
389 ui.write('\n') |
389 ui.write('\n') |
390 key, i = find(cmd) |
390 aliases, i = find(cmd) |
391 # synopsis |
391 # synopsis |
392 ui.write("%s\n\n" % i[2]) |
392 ui.write("%s\n\n" % i[2]) |
393 |
393 |
394 # description |
394 # description |
395 doc = i[0].__doc__ |
395 doc = i[0].__doc__ |
397 doc = doc.splitlines(0)[0] |
397 doc = doc.splitlines(0)[0] |
398 ui.write("%s\n" % doc.rstrip()) |
398 ui.write("%s\n" % doc.rstrip()) |
399 |
399 |
400 if not ui.quiet: |
400 if not ui.quiet: |
401 # aliases |
401 # aliases |
402 aliases = ', '.join(key.split('|')[1:]) |
402 if len(aliases) > 1: |
403 if aliases: |
403 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
404 ui.write(_("\naliases: %s\n") % aliases) |
|
405 |
404 |
406 # options |
405 # options |
407 if i[1]: |
406 if i[1]: |
408 option_lists.append(("options", i[1])) |
407 option_lists.append(("options", i[1])) |
409 |
408 |
2372 |
2371 |
2373 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2372 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2374 " debugindex debugindexdot paths") |
2373 " debugindex debugindexdot paths") |
2375 |
2374 |
2376 def find(cmd): |
2375 def find(cmd): |
2377 choice = [] |
2376 """Return (aliases, command table entry) for command string.""" |
|
2377 choice = None |
2378 for e in table.keys(): |
2378 for e in table.keys(): |
2379 aliases = e.lstrip("^").split("|") |
2379 aliases = e.lstrip("^").split("|") |
2380 if cmd in aliases: |
2380 if cmd in aliases: |
2381 return e, table[e] |
2381 return aliases, table[e] |
2382 for a in aliases: |
2382 for a in aliases: |
2383 if a.startswith(cmd): |
2383 if a.startswith(cmd): |
2384 choice.append(e) |
2384 if choice: |
2385 if len(choice) == 1: |
2385 raise UnknownCommand(cmd) |
2386 e = choice[0] |
2386 else: |
2387 return e, table[e] |
2387 choice = aliases, table[e] |
|
2388 if choice: |
|
2389 return choice |
2388 |
2390 |
2389 raise UnknownCommand(cmd) |
2391 raise UnknownCommand(cmd) |
2390 |
2392 |
2391 class SignalInterrupt(Exception): |
2393 class SignalInterrupt(Exception): |
2392 """Exception raised on SIGTERM and SIGHUP.""" |
2394 """Exception raised on SIGTERM and SIGHUP.""" |
2420 except fancyopts.getopt.GetoptError, inst: |
2422 except fancyopts.getopt.GetoptError, inst: |
2421 raise ParseError(None, inst) |
2423 raise ParseError(None, inst) |
2422 |
2424 |
2423 cmd, args = args[0], args[1:] |
2425 cmd, args = args[0], args[1:] |
2424 |
2426 |
2425 i = find(cmd)[1] |
2427 aliases, i = find(cmd) |
|
2428 cmd = aliases[0] |
2426 c = list(i[1]) |
2429 c = list(i[1]) |
2427 else: |
2430 else: |
2428 cmd = None |
2431 cmd = None |
2429 c = [] |
2432 c = [] |
2430 |
2433 |