/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/debug.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
 
17
18
"""Set of flags that enable different debug behaviour.
18
19
 
19
20
These are set with eg ``-Dlock`` on the bzr command line or in
20
 
~/.config/breezy/breezy.conf debug_flags.
 
21
~/.bazaar/bazaar.conf debug_flags.
21
22
 
22
 
See `bzr help debug-flags` or `breezy/help_topics/en/debug-flags.txt`
 
23
See `bzr help debug-flags` or `bzrlib/help_topics/en/debug-flags.txt`
23
24
for a list of the available options.
24
25
"""
25
26
 
26
 
from __future__ import absolute_import
27
27
 
28
28
debug_flags = set()
29
29
 
31
31
def set_debug_flags_from_config():
32
32
    """Turn on debug flags based on the global configuration"""
33
33
 
34
 
    from breezy import config
35
 
 
36
 
    c = config.GlobalStack()
37
 
    for f in c.get('debug_flags'):
38
 
        debug_flags.add(f)
39
 
 
40
 
 
41
 
def set_trace():
42
 
    """Pdb using original stdin and stdout.
43
 
 
44
 
    When debugging blackbox tests, sys.stdin and sys.stdout are captured for
45
 
    test purposes and cannot be used for interactive debugging. This class uses
46
 
    the origianl stdin/stdout to allow such use.
47
 
 
48
 
    Instead of doing:
49
 
 
50
 
       import pdb; pdb.set_trace()
51
 
 
52
 
    you can do:
53
 
 
54
 
       from breezy import debug; debug.set_trace()
55
 
    """
56
 
    import pdb
57
 
    import sys
58
 
    pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__
59
 
            ).set_trace(sys._getframe().f_back)
 
34
    from bzrlib.config import GlobalConfig
 
35
 
 
36
    c = GlobalConfig()
 
37
    value = c.get_user_option("debug_flags")
 
38
    if value is not None:
 
39
        # configobject gives us either a string if there's just one or a list
 
40
        # if there's multiple
 
41
        if isinstance(value, basestring):
 
42
            value = [value]
 
43
        for w in value:
 
44
            w = w.strip()
 
45
            debug_flags.add(w)