~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: John Arbash Meinel
  • Date: 2006-04-25 15:05:42 UTC
  • mfrom: (1185.85.85 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060425150542-c7b518dca9928691
[merge] the old bzr-encoding changes, reparenting them on bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Commit message editor support."""
21
21
 
 
22
import codecs
22
23
import os
23
24
import errno
24
25
from subprocess import call
25
26
 
 
27
import bzrlib
26
28
import bzrlib.config as config
27
29
from bzrlib.errors import BzrError
28
30
 
92
94
        if infotext is not None and infotext != "":
93
95
            hasinfo = True
94
96
            msgfile = file(msgfilename, "w")
95
 
            msgfile.write("\n\n%s\n\n%s" % (ignoreline, infotext))
 
97
            msgfile.write("\n\n%s\n\n%s" % (ignoreline,
 
98
                infotext.encode(bzrlib.user_encoding, 'replace')))
96
99
            msgfile.close()
97
100
        else:
98
101
            hasinfo = False
103
106
        started = False
104
107
        msg = []
105
108
        lastline, nlines = 0, 0
106
 
        for line in file(msgfilename, "r"):
 
109
        for line in codecs.open(msgfilename, 'r', bzrlib.user_encoding):
107
110
            stripped_line = line.strip()
108
111
            # strip empty line before the log message starts
109
112
            if not started:
133
136
    finally:
134
137
        # delete the msg file in any case
135
138
        try: os.unlink(msgfilename)
136
 
        except IOError: pass
 
139
        except (IOError, OSError), e:
 
140
            if (not hasattr(e, 'errno')
 
141
                or e.errno not in (errno.ENOENT, errno.ENOTDIR,
 
142
                                   errno.EPERM, errno.EACCES)):
 
143
                raise
137
144
 
138
145
 
139
146
def make_commit_message_template(working_tree, specific_files):