~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

Abbreviate pack_stat struct format to '>6L'

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    except KeyError:
42
42
        pass
43
43
 
44
 
    e = config.GlobalConfig().get_editor()
 
44
    e = config.GlobalStack().get('editor')
45
45
    if e is not None:
46
46
        yield e, config.config_filename()
47
47
 
144
144
        if not msgfilename:
145
145
            return None
146
146
        basename = osutils.basename(msgfilename)
147
 
        msg_transport = transport.get_transport(osutils.dirname(msgfilename))
 
147
        msg_transport = transport.get_transport_from_path(osutils.dirname(msgfilename))
148
148
        reference_content = msg_transport.get_bytes(basename)
149
149
        if not _run_editor(msgfilename):
150
150
            return None
151
151
        edited_content = msg_transport.get_bytes(basename)
152
152
        if edited_content == reference_content:
153
153
            if not ui.ui_factory.confirm_action(
154
 
                "Commit message was not edited, use anyway",
 
154
                u"Commit message was not edited, use anyway",
155
155
                "bzrlib.msgeditor.unchanged",
156
156
                {}):
157
157
                # Returning "" makes cmd_commit raise 'empty commit message
303
303
        These are all empty initially.
304
304
        """
305
305
        Hooks.__init__(self, "bzrlib.msgeditor", "hooks")
 
306
        self.add_hook('set_commit_message',
 
307
            "Set a fixed commit message. "
 
308
            "set_commit_message is called with the "
 
309
            "bzrlib.commit.Commit object (so you can also change e.g. revision "
 
310
            "properties by editing commit.builder._revprops) and the message "
 
311
            "so far. set_commit_message must return the message to use or None"
 
312
            " if it should use the message editor as normal.", (2, 4))
306
313
        self.add_hook('commit_message_template',
307
314
            "Called when a commit message is being generated. "
308
315
            "commit_message_template is called with the bzrlib.commit.Commit "
309
316
            "object and the message that is known so far. "
310
317
            "commit_message_template must return a new message to use (which "
311
 
            "could be the same as it was given. When there are multiple "
 
318
            "could be the same as it was given). When there are multiple "
312
319
            "hooks registered for commit_message_template, they are chained "
313
320
            "with the result from the first passed into the second, and so "
314
321
            "on.", (1, 10))
317
324
hooks = MessageEditorHooks()
318
325
 
319
326
 
 
327
def set_commit_message(commit, start_message=None):
 
328
    """Sets the commit message.
 
329
    :param commit: Commit object for the active commit.
 
330
    :return: The commit message or None to continue using the message editor
 
331
    """
 
332
    start_message = None
 
333
    for hook in hooks['set_commit_message']:
 
334
        start_message = hook(commit, start_message)
 
335
    return start_message
 
336
 
 
337
 
320
338
def generate_commit_message_template(commit, start_message=None):
321
339
    """Generate a commit message template.
322
340