Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 943:e8e5db72ed51
Add --cwd global option, to change directory before doing anything.
Useful for interacting with a program presenting a UI, such as Emacs.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 18 Aug 2005 14:58:14 -0800 |
parents | 7eb8cbcca7c4 |
children | 6d21a3488df9 |
comparison
equal
deleted
inserted
replaced
942:7eb8cbcca7c4 | 943:e8e5db72ed51 |
---|---|
1402 | 1402 |
1403 globalopts = [('v', 'verbose', None, 'verbose mode'), | 1403 globalopts = [('v', 'verbose', None, 'verbose mode'), |
1404 ('', 'debug', None, 'debug mode'), | 1404 ('', 'debug', None, 'debug mode'), |
1405 ('q', 'quiet', None, 'quiet mode'), | 1405 ('q', 'quiet', None, 'quiet mode'), |
1406 ('', 'profile', None, 'profile'), | 1406 ('', 'profile', None, 'profile'), |
1407 ('C', 'cwd', '', 'change working directory'), | |
1407 ('R', 'repository', "", 'repository root directory'), | 1408 ('R', 'repository', "", 'repository root directory'), |
1408 ('', 'traceback', None, 'print traceback on exception'), | 1409 ('', 'traceback', None, 'print traceback on exception'), |
1409 ('y', 'noninteractive', None, 'run non-interactively'), | 1410 ('y', 'noninteractive', None, 'run non-interactively'), |
1410 ('', 'version', None, 'output version information and exit'), | 1411 ('', 'version', None, 'output version information and exit'), |
1411 ('', 'time', None, 'time how long the command takes'), | 1412 ('', 'time', None, 'time how long the command takes'), |
1489 except UnknownCommand, inst: | 1490 except UnknownCommand, inst: |
1490 u = ui.ui() | 1491 u = ui.ui() |
1491 u.warn("hg: unknown command '%s'\n" % inst.args[0]) | 1492 u.warn("hg: unknown command '%s'\n" % inst.args[0]) |
1492 help_(u, 'shortlist') | 1493 help_(u, 'shortlist') |
1493 sys.exit(1) | 1494 sys.exit(1) |
1495 | |
1496 if options['cwd']: | |
1497 try: | |
1498 os.chdir(options['cwd']) | |
1499 except OSError, inst: | |
1500 u = ui.ui() | |
1501 u.warn('abort: %s: %s\n' % (options['cwd'], inst.strerror)) | |
1502 sys.exit(1) | |
1494 | 1503 |
1495 if options["time"]: | 1504 if options["time"]: |
1496 def get_times(): | 1505 def get_times(): |
1497 t = os.times() | 1506 t = os.times() |
1498 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() | 1507 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |