Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 1047:a0538ea1ac50
Moved special handling of --version and no hg command from parse to dispatch.
This allows e.g. 'hg status --version' to work.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 26 Aug 2005 08:26:21 +0200 |
parents | 772507daaa17 |
children | 7fbb440b2e63 |
comparison
equal
deleted
inserted
replaced
1046:772507daaa17 | 1047:a0538ea1ac50 |
---|---|
1554 try: | 1554 try: |
1555 args = fancyopts.fancyopts(args, globalopts, options) | 1555 args = fancyopts.fancyopts(args, globalopts, options) |
1556 except fancyopts.getopt.GetoptError, inst: | 1556 except fancyopts.getopt.GetoptError, inst: |
1557 raise ParseError(None, inst) | 1557 raise ParseError(None, inst) |
1558 | 1558 |
1559 if options["version"]: | 1559 if args: |
1560 return ("version", show_version, [], options, cmdoptions) | 1560 cmd, args = args[0], args[1:] |
1561 elif not args: | 1561 i = find(cmd)[1] |
1562 return ("help", help_, ["shortlist"], options, cmdoptions) | 1562 c = list(i[1]) |
1563 else: | 1563 else: |
1564 cmd, args = args[0], args[1:] | 1564 cmd = None |
1565 | 1565 c = [] |
1566 i = find(cmd)[1] | |
1567 | 1566 |
1568 # combine global options into local | 1567 # combine global options into local |
1569 c = list(i[1]) | |
1570 for o in globalopts: | 1568 for o in globalopts: |
1571 c.append((o[0], o[1], options[o[1]], o[3])) | 1569 c.append((o[0], o[1], options[o[1]], o[3])) |
1572 | 1570 |
1573 try: | 1571 try: |
1574 args = fancyopts.fancyopts(args, c, cmdoptions) | 1572 args = fancyopts.fancyopts(args, c, cmdoptions) |
1579 for o in globalopts: | 1577 for o in globalopts: |
1580 n = o[1] | 1578 n = o[1] |
1581 options[n] = cmdoptions[n] | 1579 options[n] = cmdoptions[n] |
1582 del cmdoptions[n] | 1580 del cmdoptions[n] |
1583 | 1581 |
1584 return (cmd, i[0], args, options, cmdoptions) | 1582 return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
1585 | 1583 |
1586 def dispatch(args): | 1584 def dispatch(args): |
1587 signal.signal(signal.SIGTERM, catchterm) | 1585 signal.signal(signal.SIGTERM, catchterm) |
1588 try: | 1586 try: |
1589 signal.signal(signal.SIGHUP, catchterm) | 1587 signal.signal(signal.SIGHUP, catchterm) |
1632 u = ui.ui(options["verbose"], options["debug"], options["quiet"], | 1630 u = ui.ui(options["verbose"], options["debug"], options["quiet"], |
1633 not options["noninteractive"]) | 1631 not options["noninteractive"]) |
1634 | 1632 |
1635 try: | 1633 try: |
1636 try: | 1634 try: |
1635 if options['version']: | |
1636 show_version(u) | |
1637 sys.exit(0) | |
1638 elif not cmd: | |
1639 help_(u, 'shortlist') | |
1640 sys.exit(0) | |
1641 | |
1637 if cmd not in norepo.split(): | 1642 if cmd not in norepo.split(): |
1638 path = options["repository"] or "" | 1643 path = options["repository"] or "" |
1639 repo = hg.repository(ui=u, path=path) | 1644 repo = hg.repository(ui=u, path=path) |
1640 d = lambda: func(u, repo, *args, **cmdoptions) | 1645 d = lambda: func(u, repo, *args, **cmdoptions) |
1641 else: | 1646 else: |