# HG changeset patch
# User Matt Harbison <
matt_h...@yahoo.com>
# Date 1687448549 14400
# Thu Jun 22 11:42:29 2023 -0400
# Branch stable
# Node ID 701d61540dda76d92b3701ffe63eb19bba0558c7
# Parent c3ee78109fde3ebebcf5601169046e6a4fb3b99d
# EXP-Topic docklog-fix
docklog: avoid a crash on tab completion with py3 (fixes #5906)
diff --git a/tortoisehg/hgqt/docklog.py b/tortoisehg/hgqt/docklog.py
--- a/tortoisehg/hgqt/docklog.py
+++ b/tortoisehg/hgqt/docklog.py
@@ -8,6 +8,11 @@
import os
+from typing import (
+ Dict,
+ List,
+ Tuple,
+)
from .qsci import (
QsciScintilla,
@@ -323,7 +328,7 @@
else:
self._logwidget.flash()
- def _commandComplete(self, cmdtype, cmdline):
+ def _commandComplete(self, cmdtype: str, cmdline: str) -> List[str]:
from tortoisehg.hgqt import run
matches = []
cmd = cmdline.split()
@@ -334,12 +339,12 @@
subcmd = ''
if len(cmd) >= 2:
subcmd = cmd[1].lower()
- def findhgcmd(cmdstart):
+ def findhgcmd(cmdstart: str) -> Dict[str, str]:
matchinfo = {}
for cmdspec in cmdtable:
- for cmdname in cmdspec.split('|'):
- if cmdname.startswith(cmdstart):
- matchinfo[cmdname] = cmdspec
+ for cmdname in cmdspec.split(b'|'):
+ if cmdname.startswith(hglib.fromunicode(cmdstart)):
+ matchinfo[hglib.tounicode(cmdname)] = hglib.tounicode(cmdspec)
return matchinfo
matchingcmds = findhgcmd(subcmd)
if not matchingcmds:
@@ -349,21 +354,21 @@
matches = [basecmdline % c for c in matchingcmds]
else:
scmdtype = list(matchingcmds)[0]
- cmdspec = matchingcmds[scmdtype]
- opts = cmdtable[cmdspec][1]
- def findcmdopt(cmdopt):
+ cmdspec = hglib.fromunicode(matchingcmds[scmdtype])
+ opts: List[Tuple[bytes]] = cmdtable[cmdspec][1]
+ def findcmdopt(cmdopt: str) -> List[Tuple[str]]:
cmdopt = cmdopt.lower()
while cmdopt.startswith('-'):
cmdopt = cmdopt[1:]
matchingopts = []
for opt in opts:
- if opt[1].startswith(cmdopt):
- matchingopts.append(opt)
+ if opt[1].startswith(hglib.fromunicode(cmdopt)):
+ matchingopts.append(tuple(hglib.tounicode(o) for o in opt))
return matchingopts
basecmdline = '%s %s --%%s' % (cmdtype, scmdtype)
if len(cmd) == 2:
matches = ['%s %s ' % (cmdtype, scmdtype)]
- matches += [basecmdline % opt[1] for opt in opts]
+ matches += [basecmdline % hglib.tounicode(opt[1]) for opt in opts]
else:
cmdopt = cmd[-1]
if cmdopt.startswith('-'):