Mercurial > forks > mercurial
changeset 53147:73094563a4a7
contrib: delete debugshell extension
The extension's functionality has been moved into core Mercurial. It has
been replaced with a placeholder rather than deleted outright to avoid
breaking existing user configs.
author | Arun Kulshreshtha <akulshreshtha@janestreet.com> |
---|---|
date | Sun, 23 Feb 2025 19:02:24 -0500 |
parents | 61ef3723e595 |
children | a69b39d79696 |
files | contrib/debugshell.py |
diffstat | 1 files changed, 10 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/debugshell.py Fri Feb 21 13:46:52 2025 -0500 +++ b/contrib/debugshell.py Sun Feb 23 19:02:24 2025 -0500 @@ -1,64 +1,16 @@ -# debugshell extension -"""a python shell with repo, changelog & manifest objects""" - -import code -import mercurial -import sys -from mercurial import ( - demandimport, - pycompat, - registrar, -) +"""a python shell with repo, changelog & manifest objects (DEPRECATED) -cmdtable = {} -command = registrar.command(cmdtable) - +The functionality of this extension has been included in core Mercurial since +version 7.1. Please use the core :hg:`debugshell` command instead. +""" -def pdb(ui, repo, msg, **opts): - objects = { - 'mercurial': mercurial, - 'repo': repo, - 'cl': repo.changelog, - 'mf': repo.manifestlog, - } +from __future__ import annotations - code.interact(msg, local=objects) +from mercurial import cmdutil, commands -def ipdb(ui, repo, msg, **opts): - import IPython - - cl = repo.changelog - mf = repo.manifestlog - cl, mf # use variables to appease pyflakes - - IPython.embed() - - -@command(b'debugshell|dbsh', []) -def debugshell(ui, repo, **opts): - bannermsg = "loaded repo : %s\n" "using source: %s" % ( - pycompat.sysstr(repo.root), - mercurial.__path__[0], - ) - - pdbmap = {'pdb': 'code', 'ipdb': 'IPython'} +def uisetup(ui): + choice, _allcmds = cmdutil.findpossible(b'dbsh', commands.table) - debugger = ui.config(b"ui", b"debugger") - if not debugger: - debugger = 'pdb' - else: - debugger = pycompat.sysstr(debugger) - - # if IPython doesn't exist, fallback to code.interact - try: - with demandimport.deactivated(): - __import__(pdbmap[debugger]) - except ImportError: - ui.warnnoi18n( - b"%s debugger specified but %s module was not found\n" - % (debugger, pdbmap[debugger]) - ) - debugger = b'pdb' - - getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts) + if b'dbsh' not in choice and ui.config(b'alias', b'dbsh', None) is None: + ui.setconfig(b'alias', b'dbsh', b'debugshell', source=b'debugshell')