/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
 
497
497
        Functions will be called in LIFO order.
498
498
        """
499
 
        self._exit_stack.callback(cleanup_func, *args, **kwargs)
 
499
        self._operation.add_cleanup(cleanup_func, *args, **kwargs)
500
500
 
501
501
    def cleanup_now(self):
502
502
        """Execute and empty pending cleanup functions immediately.
511
511
        as it releases all resources, this may release locks that the command
512
512
        wants to hold, so use should be done with care.
513
513
        """
514
 
        self._exit_stack.close()
515
 
 
516
 
    def enter_context(self, cm):
517
 
        return self._exit_stack.enter_context(cm)
 
514
        self._operation.cleanup_now()
518
515
 
519
516
    def _usage(self):
520
517
        """Return single-line grammar for this command.
782
779
        def run(*args, **kwargs):
783
780
            for hook in Command.hooks['pre_command']:
784
781
                hook(self)
 
782
            self._operation = cleanup.OperationWithCleanups(class_run)
785
783
            try:
786
 
                with cleanup.ExitStack() as self._exit_stack:
787
 
                    return class_run(*args, **kwargs)
 
784
                return self._operation.run_simple(*args, **kwargs)
788
785
            finally:
 
786
                del self._operation
789
787
                for hook in Command.hooks['post_command']:
790
788
                    hook(self)
791
789
        self.run = run
801
799
        an exception to raise up.
802
800
 
803
801
        This method is automatically wrapped by Command.__init__ with a
804
 
        ExitStack, stored as self._exit_stack. This can be used
 
802
        cleanup operation, stored as self._operation. This can be used
805
803
        via self.add_cleanup to perform automatic cleanups at the end of
806
804
        run().
807
805
 
974
972
def apply_coveraged(the_callable, *args, **kwargs):
975
973
    import coverage
976
974
    cov = coverage.Coverage()
977
 
    try:
978
 
        config_file = cov.config.config_file
979
 
    except AttributeError:  # older versions of coverage
980
 
        config_file = cov.config_file
981
 
    os.environ['COVERAGE_PROCESS_START'] = config_file
 
975
    os.environ['COVERAGE_PROCESS_START'] = cov.config_file
982
976
    cov.start()
983
977
    try:
984
978
        return exception_to_return_code(the_callable, *args, **kwargs)