~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Martin Pool
  • Date: 2006-06-20 07:55:43 UTC
  • mfrom: (1798 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1799.
  • Revision ID: mbp@sourcefrog.net-20060620075543-b10f6575d4a4fa32
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Commit message editor support."""
19
19
 
20
 
 
 
20
import codecs
21
21
import errno
22
22
import os
23
23
from subprocess import call
24
24
import sys
25
25
 
 
26
import bzrlib
26
27
import bzrlib.config as config
27
28
from bzrlib.errors import BzrError
 
29
from bzrlib.trace import warning, mutter
28
30
 
29
31
 
30
32
def _get_editor():
55
57
    for e in _get_editor():
56
58
        edargs = e.split(' ')
57
59
        try:
 
60
            ## mutter("trying editor: %r", (edargs +[filename]))
58
61
            x = call(edargs + [filename])
59
62
        except OSError, e:
60
63
           # We're searching for an editor, so catch safe errors and continue
96
99
        if infotext is not None and infotext != "":
97
100
            hasinfo = True
98
101
            msgfile = file(msgfilename, "w")
99
 
            msgfile.write("\n%s\n\n%s" % (ignoreline, infotext))
 
102
            msgfile.write("\n\n%s\n\n%s" % (ignoreline,
 
103
                infotext.encode(bzrlib.user_encoding, 'replace')))
100
104
            msgfile.close()
101
105
        else:
102
106
            hasinfo = False
107
111
        started = False
108
112
        msg = []
109
113
        lastline, nlines = 0, 0
110
 
        for line in file(msgfilename, "r"):
 
114
        for line in codecs.open(msgfilename, 'r', bzrlib.user_encoding):
111
115
            stripped_line = line.strip()
112
116
            # strip empty line before the log message starts
113
117
            if not started:
140
144
            try:
141
145
                os.unlink(msgfilename)
142
146
            except IOError, e:
143
 
                mutter("failed to unlink %s: %s; ignored", msgfilename, e)
 
147
                warning("failed to unlink %s: %s; ignored", msgfilename, e)
144
148
 
145
149
 
146
150
def make_commit_message_template(working_tree, specific_files):