sapling/dbg.py
Ryan McElroy 2536c27cf5 dbg: an extension for a quick hg REPL
Summary:
I've found this enormously useful for quickly trying things out on a repo.
I wish I could get it to work with ipython (probably requires a python upgrade),
but this is better than nothing.

Test Plan:
I've used it many times. For example:

```
$ hg dbg
--Return--
> /home/rmcelroy/dbg.py(13)debug_()->None
-> pdb.set_trace()
(Pdb) from mercurial import scmutil, node
(Pdb) x = repo[None].node()
(Pdb) node.hex(x)
*** TypeError: b2a_hex() argument 1 must be string or read-only buffer, not None
(Pdb) x = repo['tip'].node()
(Pdb) node.hex(x)
'd32c8d91739957f3f9f587e14530c3bf222b1227'
```

Reviewers: durham, pyd, davidsp, daviser, mitrandir, ericsumner, sid0

Reviewed By: ericsumner

Differential Revision: https://phabricator.fb.com/D1867702

Signature: t1:1867702:1424804512:c6d9fb6500a9db76eb1a0b99b1f565a33500ceb7
2015-02-24 10:50:23 -08:00

14 lines
250 B
Python

from mercurial import cmdutil
import pdb
cmdtable = {}
command = cmdutil.command(cmdtable)
testedwith = 'internal'
@command('dbg', [])
def debug_(ui, repo):
"""
Open up a python debugger within a command context
"""
pdb.set_trace()