py3: make contrib/debugshell.py work with Python 3
authorPulkit Goyal <pulkit@yandex-team.ru>
Thu, 28 Feb 2019 03:48:07 +0530
changeset 41814 b10bbbe995eb
parent 41813 b38c7304974f
child 41815 c7fc463b8e8e
py3: make contrib/debugshell.py work with Python 3 I changed default mercurial installation of my personal laptop to one installed with python 3.7. debugshell is one of the extension which I have enabled and it was failing. This patch makes debugshell works with Python 3. I found that chg does not work with python 3. Differential Revision: https://phab.mercurial-scm.org/D6031
contrib/debugshell.py
--- a/contrib/debugshell.py	Wed Feb 27 16:34:58 2019 -0800
+++ b/contrib/debugshell.py	Thu Feb 28 03:48:07 2019 +0530
@@ -7,6 +7,7 @@
 import sys
 from mercurial import (
     demandimport,
+    pycompat,
     registrar,
 )
 
@@ -32,10 +33,10 @@
 
     IPython.embed()
 
-@command('debugshell|dbsh', [])
+@command(b'debugshell|dbsh', [])
 def debugshell(ui, repo, **opts):
     bannermsg = ("loaded repo : %s\n"
-                 "using source: %s" % (repo.root,
+                 "using source: %s" % (pycompat.sysstr(repo.root),
                                        mercurial.__path__[0]))
 
     pdbmap = {
@@ -43,17 +44,19 @@
         'ipdb' : 'IPython'
     }
 
-    debugger = ui.config("ui", "debugger")
+    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.warn(("%s debugger specified but %s module was not found\n")
+        ui.warn((b"%s debugger specified but %s module was not found\n")
                 % (debugger, pdbmap[debugger]))
-        debugger = 'pdb'
+        debugger = b'pdb'
 
     getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)