~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Martin Pool
  • Date: 2006-04-28 09:50:03 UTC
  • mto: This revision was merged to the branch mainline in revision 1691.
  • Revision ID: mbp@sourcefrog.net-20060428095003-eb70f67db515354d
(patch) better detection of the write commit message editor to use (mpe, robertc)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Bazaar-NG -- distributed version control
2
 
 
3
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
4
2
 
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
42
40
    except KeyError:
43
41
        pass
44
42
 
45
 
    if os.name == "nt":
46
 
        yield "notepad.exe"
47
 
    elif os.name == "posix":
48
 
        yield "/usr/bin/vi"
 
43
    if sys.platform == 'win32':
 
44
        for editor in 'wordpad.exe', 'notepad.exe':
 
45
            yield editor
 
46
    else:
 
47
        for editor in ['vi', 'pico', 'nano', 'joe']:
 
48
            yield editor
49
49
 
50
50
 
51
51
def _run_editor(filename):
55
55
        try:
56
56
            x = call(edargs + [filename])
57
57
        except OSError, e:
58
 
           # ENOENT means no such editor
59
 
           if e.errno == errno.ENOENT:
 
58
           # We're searching for an editor, so catch safe errors and continue
 
59
           if e.errno in (errno.ENOENT, ):
60
60
               continue
61
61
           raise
62
62
        if x == 0:
65
65
            continue
66
66
        else:
67
67
            break
68
 
    raise BzrError("Could not start any editor. "
69
 
                   "Please specify $EDITOR or use ~/.bzr.conf/editor")
 
68
    raise BzrError("Could not start any editor.\nPlease specify one with:\n"
 
69
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n - $EDITOR" % \
 
70
                    config.config_filename())
70
71
 
71
72
 
72
73
DEFAULT_IGNORE_LINE = "%(bar)s %(msg)s %(bar)s" % \