~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib import (
28
28
    add,
29
29
    bzrdir,
 
30
    hooks,
30
31
    )
31
32
from bzrlib.osutils import dirname
32
33
from bzrlib.revisiontree import RevisionTree
183
184
            revprops['author'] = author
184
185
        # args for wt.commit start at message from the Commit.commit method,
185
186
        args = (message, ) + args
 
187
        for hook in MutableTree.hooks['start_commit']:
 
188
            hook(self)
186
189
        committed_id = commit.Commit().commit(working_tree=self,
187
190
            revprops=revprops, *args, **kwargs)
188
191
        return committed_id
466
469
        self.set_parent_trees([(new_revid, rev_tree)])
467
470
 
468
471
 
 
472
class MutableTreeHooks(hooks.Hooks):
 
473
    """A dictionary mapping a hook name to a list of callables for mutabletree 
 
474
    hooks.
 
475
    """
 
476
 
 
477
    def __init__(self):
 
478
        """Create the default hooks.
 
479
 
 
480
        """
 
481
        hooks.Hooks.__init__(self)
 
482
        # Invoked before a commit is done in a tree. New in 1.4
 
483
        self['start_commit'] = []
 
484
 
 
485
 
 
486
# install the default hooks into the MutableTree class.
 
487
MutableTree.hooks = MutableTreeHooks()
 
488
 
 
489
 
469
490
class _FastPath(object):
470
491
    """A path object with fast accessors for things like basename."""
471
492