~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: 2010-04-07 23:40:39 UTC
  • mfrom: (5137.1.2 commit)
  • Revision ID: pqm@pqm.ubuntu.com-20100407234039-52svwnj557wnywlm
(robertc) bzr commit will prompt before using a commit message that was
 generated by a template and not edited by the user. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    config,
28
28
    osutils,
29
29
    trace,
 
30
    transport,
 
31
    ui,
30
32
    )
31
33
from bzrlib.errors import BzrError, BadCommitMessageEncoding
32
34
from bzrlib.hooks import HookPoint, Hooks
139
141
    try:
140
142
        msgfilename, hasinfo = _create_temp_file_with_commit_template(
141
143
                                    infotext, ignoreline, start_message)
142
 
 
143
 
        if not msgfilename or not _run_editor(msgfilename):
144
 
            return None
145
 
 
 
144
        if not msgfilename:
 
145
            return None
 
146
        basename = osutils.basename(msgfilename)
 
147
        msg_transport = transport.get_transport(osutils.dirname(msgfilename))
 
148
        reference_content = msg_transport.get_bytes(basename)
 
149
        if not _run_editor(msgfilename):
 
150
            return None
 
151
        edited_content = msg_transport.get_bytes(basename)
 
152
        if edited_content == reference_content:
 
153
            if not ui.ui_factory.get_boolean(
 
154
                "Commit message was not edited, use anyway"):
 
155
                # Returning "" makes cmd_commit raise 'empty commit message
 
156
                # specified' which is a reasonable error, given the user has
 
157
                # rejected using the unedited template.
 
158
                return ""
146
159
        started = False
147
160
        msg = []
148
161
        lastline, nlines = 0, 0