/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 bzrlib/cleanup.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-12 22:36:23 UTC
  • mfrom: (4953 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4955.
  • Revision ID: john@arbash-meinel.com-20100112223623-836x5mou0gm5vsep
merge bzr.dev 4953 to clean up the ui factory issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
 
92
92
    where `some_func` is::
93
93
 
94
 
        def some_func(operation, args, ...)
 
94
        def some_func(operation, args, ...):
95
95
            do_something()
96
96
            operation.add_cleanup(something)
97
97
            # etc
98
98
 
99
99
    Note that the first argument passed to `some_func` will be the
100
 
    OperationWithCleanups object.
 
100
    OperationWithCleanups object.  To invoke `some_func` without that, use
 
101
    `run_simple` instead of `run`.
101
102
    """
102
103
 
103
104
    def __init__(self, func):
116
117
        return _do_with_cleanups(
117
118
            self.cleanups, self.func, self, *args, **kwargs)
118
119
 
 
120
    def run_simple(self, *args, **kwargs):
 
121
        return _do_with_cleanups(
 
122
            self.cleanups, self.func, *args, **kwargs)
 
123
 
 
124
    def cleanup_now(self):
 
125
        _run_cleanups(self.cleanups)
 
126
        self.cleanups.clear()
 
127
 
119
128
 
120
129
def _do_with_cleanups(cleanup_funcs, func, *args, **kwargs):
121
130
    """Run `func`, then call all the cleanup_funcs.