Patchwork [2,of,4] debugshell: abstract out pdb code.interact

login
register
mail settings
Submitter Sean Farley
Date Sept. 20, 2013, 8:28 p.m.
Message ID <aa9ff65add03b8e535c1.1379708911@laptop.local>
Download mbox | patch
Permalink /patch/2580/
State Accepted
Commit 3bc6753612066fe8518c5d85583ec88411166f7d
Headers show

Comments

Sean Farley - Sept. 20, 2013, 8:28 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1373821852 18000
#      Sun Jul 14 12:10:52 2013 -0500
# Node ID aa9ff65add03b8e535c115c67d5c12c64231b019
# Parent  a005dc16a698e26612f87771548aa65843c40160
debugshell: abstract out pdb code.interact
Sean Farley - Sept. 22, 2013, 4:23 a.m.
kbullock+mercurial@ringworld.org writes:

> On 20 Sep 2013, at 3:28 PM, Sean Farley wrote:
>
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1373821852 18000
>> #      Sun Jul 14 12:10:52 2013 -0500
>> # Node ID aa9ff65add03b8e535c115c67d5c12c64231b019
>> # Parent  a005dc16a698e26612f87771548aa65843c40160
>> debugshell: abstract out pdb code.interact
>
> Huh?

This was the best way I could see at the time to get pdb's code.interact
(which IPython doesn't have) into its own function :-/

Patch

diff --git a/contrib/debugshell.py b/contrib/debugshell.py
--- a/contrib/debugshell.py
+++ b/contrib/debugshell.py
@@ -2,20 +2,25 @@ 
 """a python shell with repo, changelog & manifest objects"""
 
 import mercurial
 import code
 
-def debugshell(ui, repo, **opts):
+def pdb(ui, repo, msg, **opts):
     objects = {
         'mercurial': mercurial,
         'repo': repo,
         'cl': repo.changelog,
         'mf': repo.manifest,
     }
+
+    code.interact(msg, local=objects)
+
+def debugshell(ui, repo, **opts):
     bannermsg = "loaded repo : %s\n" \
                 "using source: %s" % (repo.root,
                                       mercurial.__path__[0])
-    code.interact(bannermsg, local=objects)
+
+    pdb(ui, repo, bannermsg, **opts)
 
 cmdtable = {
     "debugshell|dbsh|db": (debugshell, [])
 }