~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-28 09:59:22 UTC
  • mfrom: (1684.1.8 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060428095922-4c5cfc2812115f2f
(mbp) commit editor improvements

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" % \
92
93
        if infotext is not None and infotext != "":
93
94
            hasinfo = True
94
95
            msgfile = file(msgfilename, "w")
95
 
            msgfile.write("\n\n%s\n\n%s" % (ignoreline, infotext))
 
96
            msgfile.write("\n%s\n\n%s" % (ignoreline, infotext))
96
97
            msgfile.close()
97
98
        else:
98
99
            hasinfo = False