At the same time we trap the editor error for all editor calls, not
just when called from "stg mail". We may want to define a new
exception for this though.
Signed-off-by: Yann Dirson <ydirson@altern.org>
- # the editor
- editor = config.get('stgit.editor')
- if editor:
- pass
- elif 'EDITOR' in os.environ:
- editor = os.environ['EDITOR']
- else:
- editor = 'vi'
- editor += ' %s' % fname
-
- print 'Invoking the editor: "%s"...' % editor,
- sys.stdout.flush()
- err = os.system(editor)
- if err:
- raise CmdException, 'editor failed, exit code: %d' % err
- print 'done'
# read the message back
f = file(fname)
# read the message back
f = file(fname)
print >> f, __comment_prefix, 'vi: set textwidth=75 filetype=diff nobackup:'
f.close()
print >> f, __comment_prefix, 'vi: set textwidth=75 filetype=diff nobackup:'
f.close()
- # the editor
- editor = config.get('stgit.editor')
- if editor:
- pass
- elif 'EDITOR' in os.environ:
- editor = os.environ['EDITOR']
- else:
- editor = 'vi'
- editor += ' %s' % fname
-
- print 'Invoking the editor: "%s"...' % editor,
- sys.stdout.flush()
- print 'done (exit code: %d)' % os.system(editor)
"""Common utility functions
"""
"""Common utility functions
"""
-import errno, os, os.path
+import errno, os, os.path, sys
+from stgit.config import config
__copyright__ = """
Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
__copyright__ = """
Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
create_dirs(os.path.dirname(full_file2))
os.rename(os.path.join(basedir, file1), full_file2)
remove_dirs(basedir, os.path.dirname(file1))
create_dirs(os.path.dirname(full_file2))
os.rename(os.path.join(basedir, file1), full_file2)
remove_dirs(basedir, os.path.dirname(file1))
+
+def call_editor(filename):
+ """Run the editor on the specified filename."""
+
+ # the editor
+ editor = config.get('stgit.editor')
+ if editor:
+ pass
+ elif 'EDITOR' in os.environ:
+ editor = os.environ['EDITOR']
+ else:
+ editor = 'vi'
+ editor += ' %s' % filename
+
+ print 'Invoking the editor: "%s"...' % editor,
+ sys.stdout.flush()
+ err = os.system(editor)
+ if err:
+ raise Exception, 'editor failed, exit code: %d' % err
+ print 'done'