~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/debug.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
for a list of the available options.
25
25
"""
26
26
 
 
27
 
27
28
debug_flags = set()
28
29
 
29
30
 
30
31
def set_debug_flags_from_config():
31
32
    """Turn on debug flags based on the global configuration"""
32
33
 
33
 
    from bzrlib import config
34
 
 
35
 
    c = config.GlobalStack()
36
 
    for f in c.get('debug_flags'):
37
 
        debug_flags.add(f)
38
 
 
39
 
 
40
 
def set_trace():
41
 
    """Pdb using original stdin and stdout.
42
 
 
43
 
    When debugging blackbox tests, sys.stdin and sys.stdout are captured for
44
 
    test purposes and cannot be used for interactive debugging. This class uses
45
 
    the origianl stdin/stdout to allow such use.
46
 
 
47
 
    Instead of doing:
48
 
 
49
 
       import pdb; pdb.set_trace()
50
 
 
51
 
    you can do:
52
 
 
53
 
       from bzrlib import debug; debug.set_trace()
54
 
    """
55
 
    import pdb
56
 
    import sys
57
 
    pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__
58
 
            ).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)