~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
690
690
        """
691
691
        class_run = self.run
692
692
        def run(*args, **kwargs):
 
693
            for hook in Command.hooks['pre_command']:
 
694
                hook(self)
693
695
            self._operation = cleanup.OperationWithCleanups(class_run)
694
696
            try:
695
697
                return self._operation.run_simple(*args, **kwargs)
696
698
            finally:
697
699
                del self._operation
 
700
                for hook in Command.hooks['post_command']:
 
701
                    hook(self)
698
702
        self.run = run
699
703
 
700
704
    def run(self):
788
792
            " is safe to mutate - e.g. to remove a command. "
789
793
            "list_commands should return the updated set of command names.",
790
794
            (1, 17))
 
795
        self.add_hook('pre_command',
 
796
            "Called prior to executing a command. Called with the command "
 
797
            "object.", (2, 6))
 
798
        self.add_hook('post_command',
 
799
            "Called after executing a command. Called with the command "
 
800
            "object.", (2, 6))
791
801
 
792
802
Command.hooks = CommandHooks()
793
803