~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-03 20:18:35 UTC
  • mfrom: (1185.82.137 w-changeset)
  • Revision ID: pqm@pqm.ubuntu.com-20060603201835-1c9a1725641ccd24
Implement bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""Commit message editor support."""
19
19
 
20
 
import codecs
 
20
 
21
21
import errno
22
22
import os
23
23
from subprocess import call
24
24
import sys
25
25
 
26
 
import bzrlib
27
26
import bzrlib.config as config
28
27
from bzrlib.errors import BzrError
29
 
from bzrlib.trace import warning, mutter
30
28
 
31
29
 
32
30
def _get_editor():
57
55
    for e in _get_editor():
58
56
        edargs = e.split(' ')
59
57
        try:
60
 
            ## mutter("trying editor: %r", (edargs +[filename]))
61
58
            x = call(edargs + [filename])
62
59
        except OSError, e:
63
60
           # We're searching for an editor, so catch safe errors and continue
99
96
        if infotext is not None and infotext != "":
100
97
            hasinfo = True
101
98
            msgfile = file(msgfilename, "w")
102
 
            msgfile.write("\n\n%s\n\n%s" % (ignoreline,
103
 
                infotext.encode(bzrlib.user_encoding, 'replace')))
 
99
            msgfile.write("\n%s\n\n%s" % (ignoreline, infotext))
104
100
            msgfile.close()
105
101
        else:
106
102
            hasinfo = False
111
107
        started = False
112
108
        msg = []
113
109
        lastline, nlines = 0, 0
114
 
        for line in codecs.open(msgfilename, 'r', bzrlib.user_encoding):
 
110
        for line in file(msgfilename, "r"):
115
111
            stripped_line = line.strip()
116
112
            # strip empty line before the log message starts
117
113
            if not started:
144
140
            try:
145
141
                os.unlink(msgfilename)
146
142
            except IOError, e:
147
 
                warning("failed to unlink %s: %s; ignored", msgfilename, e)
 
143
                mutter("failed to unlink %s: %s; ignored", msgfilename, e)
148
144
 
149
145
 
150
146
def make_commit_message_template(working_tree, specific_files):