~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-27 15:42:09 UTC
  • mfrom: (5993 +trunk)
  • mto: (5993.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5994.
  • Revision ID: v.ladeuil+lp@free.fr-20110627154209-azubuhbuxsz109hq
Merge trunk

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
 
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 "
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