##// END OF EJS Templates
debugshell: disable demand importer when importing debugger...
Gregory Szorc -
r27721:e4b512bb default
parent child Browse files
Show More
@@ -1,54 +1,58
1 1 # debugshell extension
2 2 """a python shell with repo, changelog & manifest objects"""
3 3
4 4 import sys
5 5 import mercurial
6 6 import code
7 from mercurial import cmdutil
7 from mercurial import (
8 cmdutil,
9 demandimport,
10 )
8 11
9 12 cmdtable = {}
10 13 command = cmdutil.command(cmdtable)
11 14
12 15 def pdb(ui, repo, msg, **opts):
13 16 objects = {
14 17 'mercurial': mercurial,
15 18 'repo': repo,
16 19 'cl': repo.changelog,
17 20 'mf': repo.manifest,
18 21 }
19 22
20 23 code.interact(msg, local=objects)
21 24
22 25 def ipdb(ui, repo, msg, **opts):
23 26 import IPython
24 27
25 28 cl = repo.changelog
26 29 mf = repo.manifest
27 30 cl, mf # use variables to appease pyflakes
28 31
29 32 IPython.embed()
30 33
31 34 @command('debugshell|dbsh', [])
32 35 def debugshell(ui, repo, **opts):
33 36 bannermsg = "loaded repo : %s\n" \
34 37 "using source: %s" % (repo.root,
35 38 mercurial.__path__[0])
36 39
37 40 pdbmap = {
38 41 'pdb' : 'code',
39 42 'ipdb' : 'IPython'
40 43 }
41 44
42 45 debugger = ui.config("ui", "debugger")
43 46 if not debugger:
44 47 debugger = 'pdb'
45 48
46 49 # if IPython doesn't exist, fallback to code.interact
47 50 try:
48 __import__(pdbmap[debugger])
51 with demandimport.deactivated():
52 __import__(pdbmap[debugger])
49 53 except ImportError:
50 54 ui.warn("%s debugger specified but %s module was not found\n"
51 55 % (debugger, pdbmap[debugger]))
52 56 debugger = 'pdb'
53 57
54 58 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)
General Comments 0
You need to be logged in to leave comments. Login now