changeset 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
files mercurial/commands.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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()