~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-09-04 02:59:56 UTC
  • mfrom: (1172)
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050904025956-776ba4f07de97700
Merged mpool's latest changes (~0.0.7)

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