Add --cwd global option, to change directory before doing anything.
Useful for interacting with a program presenting a UI, such as Emacs.
--- 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()