D6031: py3: make contrib/debugshell.py work with Python 3

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Feb 27 22:46:10 UTC 2019


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6031

AFFECTED FILES
  contrib/debugshell.py

CHANGE DETAILS

diff --git a/contrib/debugshell.py b/contrib/debugshell.py
--- a/contrib/debugshell.py
+++ b/contrib/debugshell.py
@@ -7,6 +7,7 @@
 import sys
 from mercurial import (
     demandimport,
+    pycompat,
     registrar,
 )
 
@@ -32,28 +33,30 @@
 
     IPython.embed()
 
- at command('debugshell|dbsh', [])
+ at command(b'debugshell|dbsh', [])
 def debugshell(ui, repo, **opts):
     bannermsg = ("loaded repo : %s\n"
-                 "using source: %s" % (repo.root,
-                                       mercurial.__path__[0]))
+                 "using source: %s" % (pycompat.sysstr(repo.root),
+                                        mercurial.__path__[0]))
 
     pdbmap = {
         'pdb'  : 'code',
         '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)



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list