~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Robert Collins
  • Date: 2005-09-14 09:01:06 UTC
  • mto: (1185.1.12)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: robertc@robertcollins.net-20050914090106-50ddfad9500a8ae9
make diff lsdiff/filterdiff friendly

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
"""Commit message editor support."""
21
21
 
22
22
import os
 
23
from subprocess import call
23
24
from bzrlib.errors import BzrError
24
25
 
25
26
def _get_editor():
30
31
    if e is not None:
31
32
        yield e
32
33
        
33
 
    if os.name == "windows":
34
 
        yield "notepad.exe"
35
 
    elif os.name == "posix":
36
 
        try:
37
 
            yield os.environ["EDITOR"]
38
 
        except KeyError:
 
34
    try:
 
35
        yield os.environ["EDITOR"]
 
36
    except KeyError:
 
37
        if os.name == "nt":
 
38
            yield "notepad.exe"
 
39
        elif os.name == "posix":
39
40
            yield "/usr/bin/vi"
40
41
 
41
42
 
43
44
    """Try to execute an editor to edit the commit message."""
44
45
    for e in _get_editor():
45
46
        edargs = e.split(' ')
46
 
        x = os.spawnvp(os.P_WAIT, edargs[0],
47
 
                       edargs + [filename])
 
47
        x = call(edargs + [filename])
48
48
        if x == 0:
49
49
            return True
50
50
        elif x == 127: