/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-10 19:59:55 UTC
  • mfrom: (1704 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060510195955-df080afb1daa3a96
[merge] bzr.dev 1704

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
20
18
"""Commit message editor support."""
21
19
 
22
20
import codecs
 
21
import errno
23
22
import os
24
 
import errno
25
23
from subprocess import call
 
24
import sys
26
25
 
27
26
import bzrlib
28
27
import bzrlib.config as config
29
28
from bzrlib.errors import BzrError
30
29
 
 
30
 
31
31
def _get_editor():
32
32
    """Return a sequence of possible editor binaries for the current platform"""
33
33
    try:
44
44
    except KeyError:
45
45
        pass
46
46
 
47
 
    if os.name == "nt":
48
 
        yield "notepad.exe"
49
 
    elif os.name == "posix":
50
 
        yield "/usr/bin/vi"
 
47
    if sys.platform == 'win32':
 
48
        for editor in 'wordpad.exe', 'notepad.exe':
 
49
            yield editor
 
50
    else:
 
51
        for editor in ['vi', 'pico', 'nano', 'joe']:
 
52
            yield editor
51
53
 
52
54
 
53
55
def _run_editor(filename):
57
59
        try:
58
60
            x = call(edargs + [filename])
59
61
        except OSError, e:
60
 
           # ENOENT means no such editor
61
 
           if e.errno == errno.ENOENT:
 
62
           # We're searching for an editor, so catch safe errors and continue
 
63
           if e.errno in (errno.ENOENT, ):
62
64
               continue
63
65
           raise
64
66
        if x == 0:
67
69
            continue
68
70
        else:
69
71
            break
70
 
    raise BzrError("Could not start any editor. "
71
 
                   "Please specify $EDITOR or use ~/.bzr.conf/editor")
 
72
    raise BzrError("Could not start any editor.\nPlease specify one with:\n"
 
73
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n - $EDITOR" % \
 
74
                    config.config_filename())
72
75
 
73
76
 
74
77
DEFAULT_IGNORE_LINE = "%(bar)s %(msg)s %(bar)s" % \