# HG changeset patch # User Bryan O'Sullivan # Date 1124405894 28800 # Node ID e8e5db72ed51d9979931ea2ce88de9c6bf5b8f4b # Parent 7eb8cbcca7c4e945c0839869e9c8740ff1ab62a6 Add --cwd global option, to change directory before doing anything. Useful for interacting with a program presenting a UI, such as Emacs. diff -r 7eb8cbcca7c4 -r e8e5db72ed51 mercurial/commands.py --- a/mercurial/commands.py Thu Aug 18 13:58:32 2005 -0800 +++ b/mercurial/commands.py Thu Aug 18 14:58:14 2005 -0800 @@ -1404,6 +1404,7 @@ ('', 'debug', None, 'debug mode'), ('q', 'quiet', None, 'quiet mode'), ('', 'profile', None, 'profile'), + ('C', 'cwd', '', 'change working directory'), ('R', 'repository', "", 'repository root directory'), ('', 'traceback', None, 'print traceback on exception'), ('y', 'noninteractive', None, 'run non-interactively'), @@ -1492,6 +1493,14 @@ help_(u, 'shortlist') sys.exit(1) + if options['cwd']: + try: + os.chdir(options['cwd']) + except OSError, inst: + u = ui.ui() + u.warn('abort: %s: %s\n' % (options['cwd'], inst.strerror)) + sys.exit(1) + if options["time"]: def get_times(): t = os.times()