Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

debugging: new file for debugging

when the os is not windows, debugging is enabled with DEBUG_THG
if the debugging variabe contains 'e', a traceback is printed when an error is passed

Changeset b3cb2803ba8f

Parent 8098f20d7996

by Simon Heimberg

Changes to one file · Browse files at b3cb2803ba8f Showing diff from parent 8098f20d7996 Diff from another changeset...

Change 1 of 1 Show Entire File tortoise/​debugthg.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@@ -0,0 +1,43 @@
+debugging = '' +try: + import _winreg + try: + hkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, + r"Software\TortoiseHg", 0, + _winreg.KEY_ALL_ACCESS) + val = QueryValueEx(hkey, 'OverlayDebug')[0] + if val in ('1', 'True'): + debugging += 'O' + val = _winreg.QueryValueEx(hkey, 'ContextMenuDebug')[0] + if val in ('1', 'True'): + debugging += 'M' + if debugging: + import win32traceutil + except EnvironmentError: + pass +except ImportError: + import os + debugging = os.environ.get("DEBUG_THG", "") + if debugging.lower() in (1, "true"): + debugging = True + +def debugf_No(str, args=None, level=''): + pass + +if debugging: + def debug(level=''): + return debugging == True or level in debugging + def debugf(str, args=None, level=''): + if not debug(level): + return + if args: + print str % args + elif debug('e') and isinstance(str, BaseException): + import traceback + traceback.print_exc() + else: + print str +else: + def debug(level=''): + return False + debugf = debugf_No