/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

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import bzrlib
27
27
import bzrlib.config as config
28
 
from bzrlib.errors import BzrError
 
28
from bzrlib.errors import BzrError, BadCommitMessageEncoding
29
29
from bzrlib.trace import warning, mutter
30
30
 
31
31
 
113
113
        # codecs.open() ALWAYS opens file in binary mode but we need text mode
114
114
        # 'rU' mode useful when bzr.exe used on Cygwin (bialix 20070430)
115
115
        f = file(msgfilename, 'rU')
116
 
        for line in codecs.getreader(bzrlib.user_encoding)(f):
117
 
            stripped_line = line.strip()
118
 
            # strip empty line before the log message starts
119
 
            if not started:
120
 
                if stripped_line != "":
121
 
                    started = True
122
 
                else:
123
 
                    continue
124
 
            # check for the ignore line only if there
125
 
            # is additional information at the end
126
 
            if hasinfo and stripped_line == ignoreline:
127
 
                break
128
 
            nlines += 1
129
 
            # keep track of the last line that had some content
130
 
            if stripped_line != "":
131
 
                lastline = nlines
132
 
            msg.append(line)
133
 
        f.close()
 
116
        try:
 
117
            try:
 
118
                for line in codecs.getreader(bzrlib.user_encoding)(f):
 
119
                    stripped_line = line.strip()
 
120
                    # strip empty line before the log message starts
 
121
                    if not started:
 
122
                        if stripped_line != "":
 
123
                            started = True
 
124
                        else:
 
125
                            continue
 
126
                    # check for the ignore line only if there
 
127
                    # is additional information at the end
 
128
                    if hasinfo and stripped_line == ignoreline:
 
129
                        break
 
130
                    nlines += 1
 
131
                    # keep track of the last line that had some content
 
132
                    if stripped_line != "":
 
133
                        lastline = nlines
 
134
                    msg.append(line)
 
135
            except UnicodeDecodeError:
 
136
                raise BadCommitMessageEncoding()
 
137
        finally:
 
138
            f.close()
134
139
 
135
140
        if len(msg) == 0:
136
141
            return ""