Part of bzrlib.library_state View In Hierarchy
This is the core state needed to make use of bzr. The current instance is currently always exposed as bzrlib.global_state, but we desired to move to a point where no global state is needed at all.
Instance Variables | saved_state | The bzrlib.global_state at the time __enter__ was called. |
cleanups | An ObjectWithCleanups which can be used for cleanups that should occur when the use of bzrlib is completed. This is initialised in __enter__ and executed in __exit__. |
Method | __init__ | Create library start for normal use of bzrlib. |
Method | __enter__ | Undocumented |
Method | __exit__ | Undocumented |
Method | _start | Do all initialization. |
Most applications that embed bzrlib, including bzr itself, should just call bzrlib.initialize(), but it is possible to use the state class directly. The initialize() function provides sensible defaults for a CLI program, such as a text UI factory.
More options may be added in future so callers should use named arguments.
BzrLibraryState implements the Python 2.5 Context Manager protocol PEP343, and can be used with the with statement. Upon __enter__ the global variables in use by bzr are set, and they are cleared on __exit__.
Parameters | ui | A bzrlib.ui.ui_factory to use. |
trace | A bzrlib.trace.Config context manager to use, perhaps bzrlib.trace.DefaultConfig. |