# Date 1736205068 18000
# Mon Jan 06 18:11:08 2025 -0500
# Branch stable
# Node ID 8e77415b51c469213c150842146176002ffb00c7
# Parent c5c323e7fa299be703df20629dee428be0013493
# EXP-Topic pyupgrade
pyupgrade: drop the usage of `typing.Text`
This is the `typing_text` fixer in `pyupgrade`. This type was meant to be for
py2/py3 interoperability, being bytes on py2 and str on py3. See hg cb769c0ffe35.
diff --git a/TortoiseHgOverlayServer.py b/TortoiseHgOverlayServer.py
--- a/TortoiseHgOverlayServer.py
+++ b/TortoiseHgOverlayServer.py
@@ -134,7 +134,7 @@
def __init__(self):
self.file = None
- def setfile(self, name: Text) -> None:
+ def setfile(self, name: str) -> None:
oname = name + '.old'
try:
rename(hglib.fromunicode(name), hglib.fromunicode(oname))
@@ -144,7 +144,7 @@
self.msg('%s, Version %s' % (APP_TITLE, version.version()))
self.msg('Logging to file started')
- def msg(self, msg: Text) -> None:
+ def msg(self, msg: str) -> None:
ts = '[%s] ' % time.strftime('%c')
f = self.file
if f:
@@ -159,7 +159,7 @@
iconcache = {}
-def load_icon(name: Text):
+def load_icon(name: str):
from tortoisehg.util.paths import get_tortoise_icon
iconPathName = get_tortoise_icon(name)
if iconPathName and os.path.isfile(iconPathName):
@@ -170,14 +170,14 @@
hicon = LoadIcon(0, win32con.IDI_APPLICATION)
return hicon
-def get_icon(name: Text):
+def get_icon(name: str):
try:
return iconcache[name]
except KeyError:
iconcache[name] = load_icon(name)
return iconcache[name]
-def SetIcon(hwnd, name: Text, add: bool = False) -> None:
+def SetIcon(hwnd, name: str, add: bool = False) -> None:
# Try and find a custom icon
if '--noicon' in sys.argv:
return
@@ -322,7 +322,7 @@
PIPEBUFSIZE = 4096
-def getrepos(batch: Iterable[Text]) -> Tuple[Set[Text], Set[Text]]:
+def getrepos(batch: Iterable[str]) -> Tuple[Set[str], Set[str]]:
roots = set()
notifypaths = set()
for path in batch:
@@ -343,7 +343,7 @@
notifypaths.add(path)
return roots, notifypaths
-def update_batch(batch: Iterable[Text]) -> None:
+def update_batch(batch: Iterable[str]) -> None:
'''updates thgstatus for all paths in batch'''
roots, notifypaths = getrepos(batch)
if roots:
@@ -435,7 +435,7 @@
pass
return show_taskbaricon, hgighlight_taskbaricon
-def update(args: List[Text], hwnd) -> None:
+def update(args: List[str], hwnd) -> None:
batch = []
r = args[0]
print("got update request %s (first in batch)" % r)
@@ -466,7 +466,7 @@
if show and highlight:
SetIcon(hwnd, "hg.ico")
-def remove(args: List[Text]) -> None:
+def remove(args: List[str]) -> None:
path = args[0]
logger.msg('Removing ' + path)
roots, notifypaths = getrepos([path])
@@ -486,7 +486,7 @@
if notifypaths:
shlib.shell_notify([hglib.fromunicode(p) for p in notifypaths])
-def dispatch(req, cmd: Text, args: List[Text], hwnd) -> None:
+def dispatch(req, cmd: str, args: List[str], hwnd) -> None:
print("dispatch(%s)" % req)
if cmd == 'update':
update(args, hwnd)
diff --git a/contrib/nautilus-thg.py b/contrib/nautilus-thg.py
--- a/contrib/nautilus-thg.py
+++ b/contrib/nautilus-thg.py
@@ -82,7 +82,7 @@
nofilecmds = 'about serve synch repoconfig userconfig merge unmerge'.split()
class HgExtensionDefault(GObject.GObject):
- allvfs: Dict[Text, Any]
+ allvfs: Dict[str, Any]
def __init__(self):
self.scanStack = []
@@ -113,12 +113,12 @@
self.gmon = Gio.file_new_for_path(self.notify).monitor(Gio.FileMonitorFlags.NONE, None)
self.gmon.connect('changed', self.notified)
- def icon(self, iname: Text) -> Optional[Text]:
+ def icon(self, iname: str) -> Optional[str]:
return paths.get_tortoise_icon(iname)
def get_path_for_vfs_file(self,
vfs_file,
- store: bool = True) -> Optional[Text]:
+ store: bool = True) -> Optional[str]:
if vfs_file.get_uri_scheme() != 'file':
return None
# TODO: is get_uri returing unicode?
@@ -130,7 +130,7 @@
self.allvfs[path] = vfs_file
return path
- def get_vfs(self, path: Text):
+ def get_vfs(self, path: str):
vfs = self.allvfs.get(path, None)
if vfs and vfs.is_gone():
del self.allvfs[path]
@@ -138,7 +138,7 @@
return vfs
def get_repo_for_path(self,
- path: Text) -> Optional[localrepo.localrepository]:
+ path: str) -> Optional[localrepo.localrepository]:
'''
Find mercurial repository for vfs_file
Returns hg.repo
@@ -156,9 +156,9 @@
def run_dialog(self,
menuitem,
- hgtkcmd: Text,
- cwd: Optional[Text] = None,
- files: Optional[List[Text]] = None) -> None:
+ hgtkcmd: str,
+ cwd: Optional[str] = None,
+ files: Optional[List[str]] = None) -> None:
'''
hgtkcmd - hgtk subcommand
'''
@@ -207,7 +207,7 @@
def _buildMenu(self,
menus: menuthg.thg_menu,
- files: List[Text]) -> List[Nautilus.MenuItem]:
+ files: List[str]) -> List[Nautilus.MenuItem]:
'''Build one level of a menu'''
items = []
if files:
@@ -264,7 +264,7 @@
"Version control status"),
def _get_file_status(self,
- localpath: Text,
+ localpath: str,
repo: Optional[localrepo.localrepository] = None):
cachestate = cachethg.get_state(localpath, repo)
cache2state = {cachethg.UNCHANGED: ('default', 'clean'),
@@ -297,7 +297,7 @@
if root:
self.invalidate(files, root)
- def invalidate(self, paths: List[Text], root: Text = '') -> None:
+ def invalidate(self, paths: List[str], root: str = '') -> None:
started = bool(self.inv_dirs)
if cachethg.cache_pdir == root and root not in self.inv_dirs:
cachethg.overlay_cache.clear()
@@ -325,7 +325,7 @@
self.inv_dirs.clear()
# property page borrowed from
http://www.gnome.org/~gpoo/hg/nautilus-hg/
- def __add_row(self, row, label_item: Text, label_value: Text) -> None:
+ def __add_row(self, row, label_item: str, label_value: str) -> None:
label = Gtk.Label(label_item)
label.set_use_markup(True)
label.set_alignment(1, 0)
diff --git a/tortoisehg/hgqt/archive.py b/tortoisehg/hgqt/archive.py
--- a/tortoisehg/hgqt/archive.py
+++ b/tortoisehg/hgqt/archive.py
@@ -81,9 +81,9 @@
def __init__(self,
repoagent: thgrepo.RepoAgent,
- rev: Optional[Text],
+ rev: Optional[str],
parent: Optional[QWidget] = None,
- minrev: Optional[Text] = None) -> None:
+ minrev: Optional[str] = None) -> None:
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._repoagent = repoagent
@@ -254,19 +254,19 @@
rev = self.rootrev_combo.currentText()
return hglib.fromunicode(rev)
- def get_selected_archive_type(self) -> Dict[Text, Text]:
+ def get_selected_archive_type(self) -> Dict[str, str]:
"""Return a dictionary describing the selected archive type"""
return _ARCHIVE_TYPES[self._typesradios.checkedId()]
def update_path(self) -> None:
# pytype: disable=redundant-function-type-comment
- def remove_ext(path: Text) -> Text:
+ def remove_ext(path: str) -> str:
for ext in ('.tar', '.tar.bz2', '.tar.gz', '.zip'):
if path.endswith(ext):
return path.replace(ext, '')
return path
- def remove_rev(path: Text) -> Text:
+ def remove_rev(path: str) -> str:
l = ''
for i in pycompat.xrange(self.rev_combo.count() - 1):
l += self.rev_combo.itemText(i)
@@ -278,9 +278,9 @@
if path.endswith(rev):
return path.replace(rev, '')
return path
- def add_rev(path: Text, rev: Text) -> Text:
+ def add_rev(path: str, rev: str) -> str:
return '%s_%s' % (path, rev)
- def add_ext(path: Text) -> Text:
+ def add_ext(path: str) -> str:
select = self.get_selected_archive_type()
if select['type'] != 'files':
path += select['ext']
@@ -310,7 +310,7 @@
self.compose_command()
@pyqtSlot()
- def compose_command(self) -> List[Text]:
+ def compose_command(self) -> List[str]:
content = self.content_mode.checkedId()
targetrev = hglib.tounicode(self.get_selected_rev())
if content == self._archive_content_all_files:
@@ -376,9 +376,9 @@
def createArchiveDialog(repoagent: thgrepo.RepoAgent,
- rev: Optional[Text] = None,
+ rev: Optional[str] = None,
parent: Optional[QWidget] = None,
- minrev: Optional[Text] = None) -> cmdui.CmdControlDialog:
+ minrev: Optional[str] = None) -> cmdui.CmdControlDialog:
dlg = cmdui.CmdControlDialog(parent)
dlg.setWindowTitle(_('Archive - %s') % repoagent.displayName())
dlg.setWindowIcon(qtlib.geticon('hg-archive'))
diff --git a/tortoisehg/hgqt/backout.py b/tortoisehg/hgqt/backout.py
--- a/tortoisehg/hgqt/backout.py
+++ b/tortoisehg/hgqt/backout.py
@@ -61,7 +61,7 @@
)
-def checkrev(repo: localrepo.localrepository, rev: int) -> Optional[Text]:
+def checkrev(repo: localrepo.localrepository, rev: int) -> Optional[str]:
op1, op2 = repo.dirstate.parents()
if op1 is None:
return _('Backout requires a parent revision')
@@ -375,7 +375,7 @@
self.completeChanged.emit()
@pyqtSlot(str)
- def onLinkActivated(self, cmd: Text) -> None:
+ def onLinkActivated(self, cmd: str) -> None:
if cmd == 'resolve':
dlg = resolve.ResolveDialog(self._repoagent, self)
dlg.exec()
@@ -405,13 +405,13 @@
# pytype: disable=redundant-function-type-comment
# csinfo
- def label_func(widget, item: Text, ctx: HgContext):
+ def label_func(widget, item: str, ctx: HgContext):
if item == 'rev':
return _('Revision:')
elif item == 'parents':
return _('Parents')
raise csinfo.UnknownItem()
- def data_func(widget, item: Text, ctx: HgContext):
+ def data_func(widget, item: str, ctx: HgContext):
if item == 'rev':
return _('Working Directory'), str(ctx)
elif item == 'parents':
@@ -437,7 +437,7 @@
else:
return '<a href="view">%s</a> (%s)' % (text, rev)
elif item == 'parents':
- def branch_markup(branch: Text) -> Text:
+ def branch_markup(branch: str) -> str:
opts = dict(fg='black', bg='#aaffaa')
return qtlib.markup(' %s ' % branch, **opts)
csets = []
@@ -536,7 +536,7 @@
self.msgEntry.moveCursorToEnd()
@pyqtSlot(str)
- def onLinkActivated(self, cmd: Text) -> None:
+ def onLinkActivated(self, cmd: str) -> None:
if cmd == 'view':
dlg = status.StatusDialog(self._repoagent, [], {}, self)
dlg.exec()
diff --git a/tortoisehg/hgqt/clone.py b/tortoisehg/hgqt/clone.py
--- a/tortoisehg/hgqt/clone.py
+++ b/tortoisehg/hgqt/clone.py
@@ -68,7 +68,7 @@
longopts = set(e[1] for e in entry[1])
return b'startrev' in longopts
-def _suggesteddest(src: Text, basedest: Text) -> Text:
+def _suggesteddest(src: str, basedest: str) -> str:
if '://' in basedest:
return basedest
try:
@@ -169,15 +169,15 @@
else:
return chk, text, None
- def chktext2(chklabel: Text,
+ def chktext2(chklabel: str,
stretch: Optional[int] = None) -> Tuple[QCheckBox, QLineEdit]:
# pytype gets confused if the returned tuple is sliced and returned
# without unpacking.
chk, text, _unused = chktext(chklabel, stretch=stretch)
return chk, text
- def chktext3(chklabel: Text,
- btnlabel: Text,
+ def chktext3(chklabel: str,
+ btnlabel: str,
btnslot,
stretch: Optional[int] = None) -> Tuple[QCheckBox, QLineEdit, QPushButton]:
assert btnlabel
@@ -281,17 +281,17 @@
if combo.itemText(i) != combo.currentText())
qs.setValue(key, l[:10])
- def source(self) -> Text:
+ def source(self) -> str:
return self.src_combo.currentText().strip()
- def setSource(self, url: Text) -> None:
+ def setSource(self, url: str) -> None:
self.src_combo.setCurrentIndex(self.src_combo.findText(url))
self.src_combo.setEditText(url)
- def destination(self) -> Text:
+ def destination(self) -> str:
return self.dest_combo.currentText().strip()
- def setDestination(self, url: Text) -> None:
+ def setDestination(self, url: str) -> None:
self.dest_combo.setCurrentIndex(self.dest_combo.findText(url))
self.dest_combo.setEditText(url)
@@ -299,23 +299,23 @@
def _suggestDestination(self) -> None:
self.setDestination(_suggesteddest(self.source(), self.destination()))
- def revSymbol(self) -> Text:
+ def revSymbol(self) -> str:
if not self.rev_chk.isChecked():
return ''
return self.rev_text.text().strip()
- def setRevSymbol(self, rev: Text) -> None:
+ def setRevSymbol(self, rev: str) -> None:
self.rev_chk.setChecked(bool(rev))
self.rev_text.setText(rev)
- def testOption(self, key: Text) -> bool:
+ def testOption(self, key: str) -> bool:
return self._opt_checks[key].isChecked()
- def setOption(self, key: Text, on: bool) -> None:
+ def setOption(self, key: str, on: bool) -> None:
self._opt_checks[key].setChecked(on)
@pyqtSlot()
- def _composeCommand(self) -> List[Text]:
+ def _composeCommand(self) -> List[str]:
opts = {
'verbose': True,
'config': [],
@@ -417,31 +417,31 @@
self.setCommandWidget(CloneWidget(config, cmdagent, self))
self.commandFinished.connect(self._emitCloned)
- def source(self) -> Text:
+ def source(self) -> str:
return self.commandWidget().source()
- def setSource(self, url: Text) -> None:
+ def setSource(self, url: str) -> None:
assert self.isCommandFinished()
self.commandWidget().setSource(url)
- def destination(self) -> Text:
+ def destination(self) -> str:
return self.commandWidget().destination()
- def setDestination(self, url: Text) -> None:
+ def setDestination(self, url: str) -> None:
assert self.isCommandFinished()
self.commandWidget().setDestination(url)
- def revSymbol(self) -> Text:
+ def revSymbol(self) -> str:
return self.commandWidget().revSymbol()
- def setRevSymbol(self, rev: Text) -> None:
+ def setRevSymbol(self, rev: str) -> None:
assert self.isCommandFinished()
self.commandWidget().setRevSymbol(rev)
- def testOption(self, key: Text) -> bool:
+ def testOption(self, key: str) -> bool:
return self.commandWidget().testOption(key)
- def setOption(self, key: Text, on: bool) -> None:
+ def setOption(self, key: str, on: bool) -> None:
assert self.isCommandFinished()
self.commandWidget().setOption(key, on)
diff --git a/tortoisehg/hgqt/close_branch.py b/tortoisehg/hgqt/close_branch.py
--- a/tortoisehg/hgqt/close_branch.py
+++ b/tortoisehg/hgqt/close_branch.py
@@ -65,7 +65,7 @@
hglib.tounicode(self._repo[self._rev].branch()))
form.addRow(_('Commit message:'), self.hg_commit)
- def compose_command(self) -> List[Text]:
+ def compose_command(self) -> List[str]:
rev = '%d' % self._rev
cmdline = hglib.buildcmdargs('close-head', m=self.hg_commit.text(),
r=rev)
diff --git a/tortoisehg/hgqt/cmdcore.py b/tortoisehg/hgqt/cmdcore.py
--- a/tortoisehg/hgqt/cmdcore.py
+++ b/tortoisehg/hgqt/cmdcore.py
@@ -68,10 +68,10 @@
if hglib.TYPE_CHECKING:
# pseudo implementation to help pytype (TODO: replace with attr.s)
def __init__(self,
- topic: Union[bytes, Text],
+ topic: Union[bytes, str],
pos: Optional[int],
- item: Union[bytes, Text] = b'',
- unit: Union[bytes, Text] = b'',
+ item: Union[bytes, str] = b'',
+ unit: Union[bytes, str] = b'',
total: Optional[int] = None) -> None:
super().__init__((
hglib.tounicode(topic),
@@ -116,12 +116,12 @@
self._dataout = None
def setPrompt(self,
- text: Text,
+ text: str,
mode: int,
- default: Optional[Text] = None) -> None:
+ default: Optional[str] = None) -> None:
pass
- def getLineInput(self) -> Optional[Text]:
+ def getLineInput(self) -> Optional[str]:
# '' to use default; None to abort
return ''
@@ -195,7 +195,7 @@
def stopService(self) -> None:
# {Starting,Ready,Restarting}->Stopping; *->*
pass
- def startCommand(self, cmdline: List[Text], uihandler: UiHandler) -> None:
+ def startCommand(self, cmdline: List[str], uihandler: UiHandler) -> None:
raise NotImplementedError
def abortCommand(self) -> None:
raise NotImplementedError
@@ -263,7 +263,7 @@
def __init__(self,
ui: uimod.ui,
parent: Optional[QObject] = None,
- cwd: Optional[Text] = None) -> None:
+ cwd: Optional[str] = None) -> None:
super().__init__(parent)
self._ui = ui
self._uihandler = None
@@ -276,7 +276,7 @@
proc.readyReadStandardError.connect(self._stderr)
proc.errorOccurred.connect(self._handleerror)
- def startCommand(self, cmdline: List[Text], uihandler: UiHandler) -> None:
+ def startCommand(self, cmdline: List[str], uihandler: UiHandler) -> None:
self._uihandler = uihandler
fullcmdline = _proccmdline(self._ui, _localprocexts)
fullcmdline.extend(cmdline)
@@ -336,7 +336,7 @@
def __init__(self,
ui: uimod.ui,
parent: Optional[QObject] = None,
- cwd: Optional[Text] = None) -> None:
+ cwd: Optional[str] = None) -> None:
super().__init__(parent)
self._ui = ui
self._uihandler = UiHandler()
@@ -430,7 +430,7 @@
def isCommandRunning(self) -> bool:
return self._readchtable is self._runcommandchtable
- def startCommand(self, cmdline: List[Text], uihandler: UiHandler) -> None:
+ def startCommand(self, cmdline: List[str], uihandler: UiHandler) -> None:
assert self._servicestate == CmdWorker.Ready, self._servicestate
assert not self.isCommandRunning()
try:
@@ -617,7 +617,7 @@
}
-_workertypes: Dict[Text, Callable[[uimod.ui, Optional[QObject], Optional[Text]], CmdWorker]] = {
+_workertypes: Dict[str, Callable[[uimod.ui, Optional[QObject], Optional[str]], CmdWorker]] = {
'proc': CmdProc,
'server': CmdServer,
}
@@ -637,7 +637,7 @@
readyRead = pyqtSignal()
def __init__(self,
- cmdlines: List[List[Text]],
+ cmdlines: List[List[str]],
uihandler: UiHandler,
parent: Optional[QObject] = None) -> None:
super().__init__(parent)
@@ -685,14 +685,14 @@
"""True if a command is running; False if finished or not started yet"""
return bool(self._worker) and self._qnextp > 0
- def errorString(self) -> Text:
+ def errorString(self) -> str:
"""Error message received in the last command"""
if self._abortbyuser:
return _('Terminated by user')
else:
return ''.join(self._erroroutputs).rstrip()
- def warningString(self) -> Text:
+ def warningString(self) -> str:
"""Warning message received in the last command"""
return ''.join(self._warningoutputs).rstrip()
@@ -872,8 +872,8 @@
def __init__(self,
ui: uimod.ui,
parent: Optional[QObject] = None,
- cwd: Optional[Text] = None,
- worker: Optional[Text] = None) -> None:
+ cwd: Optional[str] = None,
+ worker: Optional[str] = None) -> None:
super().__init__(parent)
self._ui = ui
self._worker = self._createWorker(cwd, worker or 'server')
@@ -922,14 +922,14 @@
sess.setParent(None)
def runCommand(self,
- cmdline: List[Text],
+ cmdline: List[str],
uihandler: Optional[Union[QWidget, UiHandler]] = None) -> CmdSession:
"""Executes a single Mercurial command asynchronously and returns
new CmdSession object"""
return self.runCommandSequence([cmdline], uihandler)
def runCommandSequence(self,
- cmdlines: List[List[Text]],
+ cmdlines: List[List[str]],
uihandler: Optional[Union[QWidget, UiHandler]] = None) -> CmdSession:
"""Executes a series of Mercurial commands asynchronously and returns
new CmdSession object which will provide notification signals.
@@ -963,7 +963,7 @@
for sess in self._sessqueue[:]:
sess.abort()
- def _createWorker(self, cwd: Optional[Text], name: Text) -> CmdWorker:
+ def _createWorker(self, cwd: Optional[str], name: str) -> CmdWorker:
self._ui.debug(b"creating cmdworker '%s'\n" % pycompat.sysbytes(name))
worker = _workertypes[name](self._ui, self, cwd)
worker.serviceStateChanged.connect(self._tryEmitServiceStopped)
diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py
+++ b/tortoisehg/hgqt/commit.py
@@ -104,10 +104,10 @@
# `opts` arg type internal to this module. Public classes use
# Dict[Text, bytes] to support @command.
- CommitOpts = Dict[Text, Union[bool, Text]]
+ CommitOpts = Dict[str, Union[bool, str]]
# TODO: simplify to just be List[Text]?
- CmdLines = List[List[Union[bytes, Text]]]
+ CmdLines = List[List[Union[bytes, str]]]
if
os.name == 'nt':
from ..util import bugtraq
@@ -133,7 +133,7 @@
return opts
-def commitopts2str(opts: CommitOpts, mode: Text = 'commit') -> Text:
+def commitopts2str(opts: CommitOpts, mode: str = 'commit') -> str:
optslist = []
for opt, value in opts.items():
if opt in ['user', 'date', 'pushafter', 'autoinc',
@@ -147,7 +147,7 @@
optslist.append('--%s=%s' % (opt, value))
return ' '.join(optslist)
-def mergecommitmessage(repo: localrepo.localrepository) -> Text:
+def mergecommitmessage(repo: localrepo.localrepository) -> str:
wctx = repo[None]
engmsg = repo.ui.configbool(b'tortoisehg', b'engmsg')
bcustommsg = repo.ui.config(b'tortoisehg', b'mergecommitmessage')
@@ -163,7 +163,7 @@
return text
def _getUserOptions(opts: CommitOpts,
- optionlist: Iterable[Text]) -> List[Text]:
+ optionlist: Iterable[str]) -> List[str]:
out = []
for opt in optionlist:
if opt not in opts:
@@ -185,9 +185,9 @@
isnew: bool,
stwidget: status.StatusWidget,
pnwidget: QLineEdit,
- message: Text,
+ message: str,
opts: CommitOpts,
- olist: Iterable[Text]) -> Optional[CmdLines]:
+ olist: Iterable[str]) -> Optional[CmdLines]:
# TODO: convert all bytes to unicode in the return value
if isnew:
name = pnwidget.text()
@@ -242,9 +242,9 @@
def __init__(self,
repoagent: RepoAgent,
pats: List[bytes],
- opts: Dict[Text, bytes],
+ opts: Dict[str, bytes],
parent: Optional[QObject] = None,
- rev: Optional[Text] = None) -> None:
+ rev: Optional[str] = None) -> None:
# TODO: drop `opts`, since it is immediately overwritten?
# TODO: make `rev` a byte string?
QWidget.__init__(self, parent)
@@ -416,11 +416,11 @@
return self._repoagent.rawRepo()
@property
- def rev(self) -> Text:
+ def rev(self) -> str:
"""Return current revision"""
return self._rev
- def selectRev(self, rev: Text) -> None:
+ def selectRev(self, rev: str) -> None:
"""
Select the revision that must be set when the dialog is shown again
"""
@@ -439,7 +439,7 @@
self.commitSetAction(refresh=True,
actionName=preferredActionName)
- def _getPreferredActionName(self) -> Text:
+ def _getPreferredActionName(self) -> str:
"""Select the preferred action, depending on the selected revision"""
if not self.hasmqbutton:
return 'commit'
@@ -510,7 +510,7 @@
def __init__(self, parent, repo):
self.repo = repo
QMenu.__init__(self, parent)
- def getActionByName(self, act: Text) -> QAction:
+ def getActionByName(self, act: str) -> QAction:
return [a for a in self.actions() if a._name == act][0]
def showEvent(self, event):
for a in self.actions():
@@ -541,7 +541,7 @@
@pyqtSlot(bool)
def commitSetAction(self,
refresh: bool = False,
- actionName: Optional[Text] = None) -> None:
+ actionName: Optional[str] = None) -> None:
# TODO: should this slot also be declared with str arg?
allowcs = False
if actionName:
@@ -690,7 +690,7 @@
self._runCommand(curraction._name, wholecmdlines)
@pyqtSlot(str, str)
- def fileDisplayed(self, wfile: Text, contents: Text) -> None:
+ def fileDisplayed(self, wfile: str, contents: str) -> None:
'Status widget is displaying a new file'
if not (wfile and contents):
return
@@ -900,7 +900,7 @@
self.msgte.setFocus()
self.refresh()
- def canUndo(self) -> Optional[Text]:
+ def canUndo(self) -> Optional[str]:
'Returns undo description or None if not valid'
desc, oldlen = hglib.readundodesc(self.repo)
if desc == 'commit':
@@ -948,7 +948,7 @@
self.setMessage(message)
self.msgte.setFocus()
- def setMessage(self, msg: Text, modified: bool = False) -> None:
+ def setMessage(self, msg: str, modified: bool = False) -> None:
self.msgte.setText(msg)
self.msgte.moveCursorToEnd()
self.msgte.setModified(modified)
@@ -958,7 +958,7 @@
return False
return self._cmdsession.isFinished()
- def loadSettings(self, s: QSettings, prefix: Text) -> None:
+ def loadSettings(self, s: QSettings, prefix: str) -> None:
'Load history, etc, from QSettings instance'
repoid = hglib.shortrepoid(self.repo)
lpref = prefix + '/commit/' # local settings (splitter, etc)
@@ -984,7 +984,7 @@
except OSError:
pass
- def saveSettings(self, s: QSettings, prefix: Text) -> None:
+ def saveSettings(self, s: QSettings, prefix: str) -> None:
'Save history, etc, in QSettings instance'
try:
repoid = hglib.shortrepoid(self.repo)
@@ -1000,14 +1000,14 @@
except OSError:
pass
- def addMessageToHistory(self, umsg: Text) -> None:
+ def addMessageToHistory(self, umsg: str) -> None:
if umsg in self.msghistory:
self.msghistory.remove(umsg)
self.msghistory.insert(0, umsg)
self.msghistory = self.msghistory[:10]
self.updateRecentMessages()
- def addUsernameToHistory(self, user: Text) -> None:
+ def addUsernameToHistory(self, user: str) -> None:
if user in self.userhist:
self.userhist.remove(user)
self.userhist.insert(0, user)
@@ -1215,7 +1215,7 @@
def stop(self):
self._cmdsession.abort()
- def _runCommand(self, action: Text, cmdlines: CmdLines) -> None:
+ def _runCommand(self, action: str, cmdlines: CmdLines) -> None:
self.currentAction = action
self.progress.emit(*cmdui.startProgress(_topicmap[action], ''))
self.commitButtonEnable.emit(False)
@@ -1259,9 +1259,9 @@
def __init__(self,
repoagent: RepoAgent,
opts: CommitOpts,
- userhistory: List[Text],
+ userhistory: List[str],
parent: QWidget,
- mode: Text = 'commit') -> None:
+ mode: str = 'commit') -> None:
QDialog.__init__(self, parent)
self.setWindowTitle(_('%s - commit options') % repoagent.displayName())
self._repoagent = repoagent
@@ -1512,7 +1512,7 @@
hglib.exception_str(e), parent=self)
def accept(self):
- outopts: Dict[Text, Text] = {}
+ outopts: Dict[str, str] = {}
if self.datecb.isChecked():
udate = self.datele.text()
date = hglib.fromunicode(udate)
@@ -1566,7 +1566,7 @@
def __init__(self,
repoagent: RepoAgent,
pats: List[bytes],
- opts: Dict[Text, bytes],
+ opts: Dict[str, bytes],
parent: Optional[QObject] = None) -> None:
QDialog.__init__(self, parent)
self.setWindowFlags(Qt.WindowType.Window)
@@ -1621,11 +1621,11 @@
self.commit.msgte.setFocus()
qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Refresh, self, self.refresh)
- def linkActivated(self, link: Text) -> None:
+ def linkActivated(self, link: str) -> None:
if link.startswith('repo:'):
self._subdialogs.open(link[len('repo:'):])
- def _createSubDialog(self, uroot: Text) -> CommitDialog:
+ def _createSubDialog(self, uroot: str) -> CommitDialog:
repoagent = self._repoagent.subRepoAgent(uroot)
return CommitDialog(repoagent, [], {}, parent=self)
diff --git a/tortoisehg/hgqt/filectxactions.py b/tortoisehg/hgqt/filectxactions.py
--- a/tortoisehg/hgqt/filectxactions.py
+++ b/tortoisehg/hgqt/filectxactions.py
@@ -74,9 +74,9 @@
from ..util.typelib import HgContext
FileData = _AbstractFileData
-_ActionTableEntry = Tuple[Text, Optional[Text], Optional[Text], Text,
+_ActionTableEntry = Tuple[str, Optional[str], Optional[str], str,
Tuple["_FileDataFilter", ...]]
-_ActionTable = Dict[Text, _ActionTableEntry]
+_ActionTable = Dict[str, _ActionTableEntry]
# The filter function type to reduce the list of input FileData entries.
_FileDataFilter = Callable[[List["FileData"]], List["FileData"]]
@@ -102,10 +102,10 @@
return [e for e in fds if e.rev() is not None and e.rev() >= 0]
# pytype: enable=unsupported-operands
-def _filepath(pat: Text) -> _FileDataFilter:
+def _filepath(pat: str) -> _FileDataFilter:
patre = re.compile(pat)
return lambda fds: [e for e in fds if patre.search(e.filePath())]
-def _filestatus(s: Text) -> _FileDataFilter:
+def _filestatus(s: str) -> _FileDataFilter:
s = frozenset(s)
# include directory since its status is unknown
return lambda fds: [e for e in fds if e.isDir() or e.fileStatus() in s]
@@ -117,7 +117,7 @@
return [e for e in fds if not e.isDir()]
def _merged(fds: List[FileData]) -> List[FileData]:
return [e for e in fds if len(e.rawContext().parents()) > 1]
-def _mergestatus(s: Text) -> _FileDataFilter:
+def _mergestatus(s: str) -> _FileDataFilter:
s = frozenset(s)
# include directory since its status is unknown
return lambda fds: [e for e in fds if e.isDir() or e.mergeStatus() in s]
@@ -134,7 +134,7 @@
if len(fds) != 1:
return []
return fds
-def _subrepotype(t: Text) -> _FileDataFilter:
+def _subrepotype(t: str) -> _FileDataFilter:
return lambda fds: [e for e in fds if e.subrepoType() == t]
def _filterby(
@@ -197,8 +197,8 @@
FilectxActions._gennavdialogkey,
self)
- self._actions: Dict[Text, _MenuActionEntry] = {}
- self._customactions: Dict[Text, _MenuActionEntry] = {}
+ self._actions: Dict[str, _MenuActionEntry] = {}
+ self._customactions: Dict[str, _MenuActionEntry] = {}
for name, d in self._actiontable.items():
desc, icon, key, tip, fdfilters = d
# QAction must be owned by QWidget; otherwise statusTip for context
@@ -245,7 +245,7 @@
for act, fdfilters in allactions:
act.setEnabled(idle and bool(_filterby(fdfilters, selfds)))
- def fileDataListForAction(self, name: Text) -> List[FileData]:
+ def fileDataListForAction(self, name: str) -> List[FileData]:
fdfilters = self._actions[name][1]
return _filterby(fdfilters, self._selfds)
@@ -257,25 +257,25 @@
"""List of the actions; The owner widget should register them"""
return [a for a, _f in self._actions.values()]
- def action(self, name: Text) -> QAction:
+ def action(self, name: str) -> QAction:
return self._actions[name][0]
def _addAction(
- self, name: Text,
+ self, name: str,
action: QAction,
fdfilters: Tuple[_FileDataFilter, ...]
) -> None:
assert name not in self._actions, name
self._actions[name] = action, fdfilters
- def _runCommand(self, cmdline: List[Text]) -> CmdSession:
+ def _runCommand(self, cmdline: List[str]) -> CmdSession:
if not self._cmdsession.isFinished():
return cmdcore.nullCmdSession()
sess = self._repoagent.runCommand(cmdline, self._parentWidget())
self._handleNewCommand(sess)
return sess
- def _runCommandSequence(self, cmdlines: List[List[Text]]) -> CmdSession:
+ def _runCommandSequence(self, cmdlines: List[List[str]]) -> CmdSession:
if not self._cmdsession.isFinished():
return cmdcore.nullCmdSession()
sess = self._repoagent.runCommandSequence(cmdlines, self._parentWidget())
@@ -556,7 +556,7 @@
currentfile = hglib.fromunicode(fd.filePath())
qtlib.openshell(root, currentfile, self._ui)
- def setupCustomToolsMenu(self, location: Text) -> None:
+ def setupCustomToolsMenu(self, location: str) -> None:
tools, toollist = hglib.tortoisehgtools(self._ui, location)
submenu = QMenu(_('Custom Tools'), self._parentWidget())
submenu.triggered.connect(self._runCustomCommandByMenu)
@@ -621,9 +621,9 @@
def _runWorkingFileCommand(
self,
- cmdname: Text,
+ cmdname: str,
fds: List[FileData],
- opts: Optional[Dict[Text, Any]]=None,
+ opts: Optional[Dict[str, Any]]=None,
) -> CmdSession:
if not opts:
opts = {}
diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
--- a/tortoisehg/hgqt/filedata.py
+++ b/tortoisehg/hgqt/filedata.py
@@ -66,7 +66,7 @@
return True
return False
-def _checkdifferror(data: bytes, maxdiff: int) -> Optional[Text]:
+def _checkdifferror(data: bytes, maxdiff: int) -> Optional[str]:
p = _('Diff not displayed: ')
size = len(data)
if size > maxdiff:
@@ -78,7 +78,7 @@
# it's incredibly slow to render long line by QScintilla
return p + _('File may be binary (maximum line length exceeded)')
-def _trimdiffheader(diff: Text) -> Text:
+def _trimdiffheader(diff: str) -> str:
# trim first three lines, for example:
# diff -r f6bfc41af6d7 -r c1b18806486d tortoisehg/hgqt/mq.py
# --- a/tortoisehg/hgqt/mq.py
@@ -98,21 +98,21 @@
ctx: HgContext,
ctx2: Optional[HgContext],
wfile: bytes,
- status: Optional[Text] = None,
+ status: Optional[str] = None,
rpath: Optional[bytes] = None,
) -> None:
self._ctx = ctx
self._pctx: Optional[HgContext] = ctx2
self._wfile = wfile
- self._status: Optional[Text] = status
+ self._status: Optional[str] = status
self._rpath: bytes = rpath or b''
self.contents: Optional[bytes] = None
- self.ucontents: Optional[Text] = None
- self.error: Optional[Text] = None
+ self.ucontents: Optional[str] = None
+ self.error: Optional[str] = None
self.olddata: Optional[bytes] = None
self.diff: Optional[bytes] = None
- self.flabel: Text = u''
- self.elabel: Text = u''
+ self.flabel: str = u''
+ self.elabel: str = u''
self.changes: Optional[patch.header] = None
self._textencoding = fileencoding.contentencoding(ctx.repo().ui)
@@ -188,46 +188,46 @@
# filePath : "foo/subrepo/bar/baz"
# repoRootPath : "foo/subrepo"
- def absoluteFilePath(self) -> Text:
+ def absoluteFilePath(self) -> str:
"""Absolute file-system path of this file"""
repo = self._ctx.repo()
return hglib.tounicode(os.path.normpath(repo.wjoin(self._wfile)))
- def absoluteRepoRootPath(self) -> Text:
+ def absoluteRepoRootPath(self) -> str:
"""Absolute file-system path to the root of the container repository"""
# repo.root should be normalized
repo = self._ctx.repo()
return hglib.tounicode(repo.root)
- def canonicalFilePath(self) -> Text:
+ def canonicalFilePath(self) -> str:
"""Path relative to the repository root which contains this file"""
return hglib.tounicode(self._wfile)
- def filePath(self) -> Text:
+ def filePath(self) -> str:
"""Path relative to the top repository root in the current context"""
return hglib.tounicode(posixpath.join(self._rpath, self._wfile))
- def repoRootPath(self) -> Text:
+ def repoRootPath(self) -> str:
"""Root path of the container repository relative to the top repository
in the current context; '' for top repository"""
return hglib.tounicode(self._rpath)
- def fileStatus(self) -> Optional[Text]:
+ def fileStatus(self) -> Optional[str]:
return self._status
def isDir(self) -> bool:
return not self._wfile
- def mergeStatus(self) -> Optional[Text]:
+ def mergeStatus(self) -> Optional[str]:
pass
- def subrepoType(self) -> Optional[Text]:
+ def subrepoType(self) -> Optional[str]:
pass
- def textEncoding(self) -> Text:
+ def textEncoding(self) -> str:
return self._textencoding
- def setTextEncoding(self, name: Text) -> None:
+ def setTextEncoding(self, name: str) -> None:
self._textencoding = fileencoding.canonname(name)
def detectTextEncoding(self) -> None:
@@ -238,13 +238,13 @@
fallbackenc = self._textencoding
self._textencoding = fileencoding.guessencoding(ui, data, fallbackenc)
- def _textToUnicode(self, s: bytes) -> Text:
+ def _textToUnicode(self, s: bytes) -> str:
return s.decode(self._textencoding, 'replace')
- def diffText(self) -> Text:
+ def diffText(self) -> str:
return self._textToUnicode(self.diff or b'')
- def fileText(self) -> Text:
+ def fileText(self) -> str:
return self._textToUnicode(self.contents or b'')
@@ -255,12 +255,12 @@
ctx: HgContext,
pctx: Optional[HgContext],
path: bytes,
- status: Optional[Text] = None,
+ status: Optional[str] = None,
rpath: Optional[bytes] = None,
- mstatus: Optional[Text] = None,
+ mstatus: Optional[str] = None,
) -> None:
super().__init__(ctx, pctx, path, status, rpath)
- self._mstatus: Optional[Text] = mstatus
+ self._mstatus: Optional[str] = mstatus
def load(self, changeselect: bool = False, force: bool = False) -> None:
if self.rev() == nullrev:
@@ -328,7 +328,7 @@
ctx: HgContext,
ctx2: Optional[HgContext],
wfile: bytes,
- status: Text,
+ status: str,
changeselect: bool,
force: bool,
) -> None:
@@ -337,7 +337,7 @@
n1: Optional[bytes],
n2: Optional[bytes],
wfile: bytes,
- ) -> Optional[Text]:
+ ) -> Optional[str]:
m = scmutil.matchfiles(repo, [wfile])
st = repo.status(n1, n2, match=m)
if wfile in st.modified:
@@ -514,10 +514,10 @@
else:
self.diff = b''
- def mergeStatus(self) -> Optional[Text]:
+ def mergeStatus(self) -> Optional[str]:
return self._mstatus
- def diffText(self) -> Text:
+ def diffText(self) -> str:
udiff = self._textToUnicode(self.diff or b'')
if self.changes:
return udiff
@@ -605,7 +605,7 @@
# patch has no comparison base
return nullrev
- def diffText(self) -> Text:
+ def diffText(self) -> str:
return _trimdiffheader(self._textToUnicode(self.diff or b''))
@@ -647,9 +647,9 @@
ctx: HgContext,
pctx: Optional[HgContext],
path: bytes,
- status: Optional[Text],
+ status: Optional[str],
rpath: Optional[bytes],
- subkind: Text,
+ subkind: str,
) -> None:
super().__init__(ctx, pctx, path, status, rpath)
self._subkind = subkind
@@ -676,8 +676,8 @@
self.flabel = u'<b>%s</b>' % self.filePath()
try:
- def genSubrepoRevChangedDescription(subrelpath: bytes, sfrom: Text, sto: Text,
- repo: localrepo.localrepository) -> Tuple[List[Text], Text]:
+ def genSubrepoRevChangedDescription(subrelpath: bytes, sfrom: str, sto: str,
+ repo: localrepo.localrepository) -> Tuple[List[str], str]:
"""Generate a subrepository revision change description"""
out = []
def getLog(_ui, srepo, opts):
@@ -888,7 +888,7 @@
def isDir(self) -> bool:
return True
- def subrepoType(self) -> Text:
+ def subrepoType(self) -> str:
return self._subkind
@@ -896,9 +896,9 @@
ctx: ThgContext,
ctx2: Optional[HgContext],
wfile: bytes,
- status: Optional[Text] = None,
+ status: Optional[str] = None,
rpath: Optional[bytes] = None,
- mstatus: Optional[Text] = None,
+ mstatus: Optional[str] = None,
) -> Union[FileData, PatchFileData]:
if isinstance(ctx, patchctx.patchctx):
if mstatus:
@@ -938,9 +938,9 @@
ctx: HgContext,
pctx: Optional[HgContext],
path: bytes,
- status: Optional[Text] = None,
+ status: Optional[str] = None,
rpath: Optional[bytes] = None,
- subkind: Optional[Text] = None,
+ subkind: Optional[str] = None,
) -> SubrepoData:
if not subkind:
subkind = pycompat.sysstr(
diff --git a/tortoisehg/hgqt/filedialogs.py b/tortoisehg/hgqt/filedialogs.py
--- a/tortoisehg/hgqt/filedialogs.py
+++ b/tortoisehg/hgqt/filedialogs.py
@@ -432,7 +432,7 @@
Qt4 dialog to display diffs between different mercurial revisions of a file.
"""
- filedata: Dict[Text, List[str]]
+ filedata: Dict[str, List[str]]
def __init__(self, repoagent, filename):
super().__init__(repoagent, filename)
diff --git a/tortoisehg/hgqt/fileencoding.py b/tortoisehg/hgqt/fileencoding.py
--- a/tortoisehg/hgqt/fileencoding.py
+++ b/tortoisehg/hgqt/fileencoding.py
@@ -47,7 +47,7 @@
#
# - no UTF-16 or -32, which is binary in Mercurial
# - no ASCII because it can be represented in other encodings
-_ENCODINGNAMES: List[Tuple[Text, Text]] = [
+_ENCODINGNAMES: List[Tuple[str, str]] = [
('utf-8', _('Unicode')),
('iso8859-1', _('Western Europe')),
('cp1252', _('Western Europe')),
@@ -85,7 +85,7 @@
]
# map to wider encoding included in the table
-_SUBSTMAP: Dict[Text, Text] = {
+_SUBSTMAP: Dict[str, str] = {
'ascii': 'utf-8',
'shift_jis': 'cp932',
}
@@ -103,10 +103,10 @@
# cp1251, koi8-r, koi8-u, iso8859-7, cp1253, cp1254, cp1256, iso8859-6,
# cp1255, iso8859-8, cp1258, iso8859-4, iso8859-13, cp1257, iso8859-3,
# iso8859-10, iso8859-14, iso8859-16
-_LOCALEENCODINGS: Text = _('$FILE_ENCODINGS').replace('$FILE_ENCODINGS', '')
+_LOCALEENCODINGS: str = _('$FILE_ENCODINGS').replace('$FILE_ENCODINGS', '')
-def canonname(name: Text) -> Text:
+def canonname(name: str) -> str:
"""Resolve aliases and substitutions of the specified encoding
>>> canonname('Shift_JIS')
@@ -124,7 +124,7 @@
name = codecs.lookup(name).name
return _SUBSTMAP.get(name, name)
-def contentencoding(ui: uimod.ui, fallbackenc: Optional[Text] = None) -> Text:
+def contentencoding(ui: uimod.ui, fallbackenc: Optional[str] = None) -> str:
"""Preferred encoding of file contents in repository"""
# assumes web.encoding is the content encoding, not the filename one
enc = pycompat.sysstr(ui.config(b'web', b'encoding'))
@@ -136,11 +136,11 @@
% pycompat.sysbytes(enc))
return canonname(fallbackenc or pycompat.sysstr(encoding.encoding))
-def knownencodings() -> List[Text]:
+def knownencodings() -> List[str]:
"""List of encoding names which are likely used"""
return [enc for enc, _region in _ENCODINGNAMES]
-def _localeencodings() -> List[Text]:
+def _localeencodings() -> List[str]:
localeencs = []
if _LOCALEENCODINGS:
localeencs.extend(canonname(e) for e in _LOCALEENCODINGS.split(','))
@@ -155,8 +155,8 @@
def guessencoding(
ui: uimod.ui,
data: bytes,
- fallbackenc: Optional[Text] = None
-) -> Text:
+ fallbackenc: Optional[str] = None
+) -> str:
"""Guess encoding of the specified data from locale-specific candidates
This is faster than chardet.detect() and works well for structured
@@ -189,7 +189,7 @@
a.setData(enc)
return group
-def addCustomAction(group: QActionGroup, name: Text) -> QAction:
+def addCustomAction(group: QActionGroup, name: str) -> QAction:
cname = canonname(name) # will raise LookupError for invalid name
a = group.addAction(name)
a.setCheckable(True)
@@ -212,20 +212,20 @@
menu.addSeparator()
menu.addActions(otheracts)
-def findActionByName(group: QActionGroup, name: Text) -> QAction:
+def findActionByName(group: QActionGroup, name: str) -> QAction:
cname = canonname(name)
for a in group.actions():
if str(a.data()) == cname:
return a
raise LookupError('no encoding action: %s' % name)
-def checkedActionName(group: QActionGroup) -> Text:
+def checkedActionName(group: QActionGroup) -> str:
a = group.checkedAction()
if not a:
return ''
return str(a.data())
-def checkActionByName(group: QActionGroup, name: Text) -> None:
+def checkActionByName(group: QActionGroup, name: str) -> None:
try:
a = findActionByName(group, name)
except LookupError:
diff --git a/tortoisehg/hgqt/graft.py b/tortoisehg/hgqt/graft.py
--- a/tortoisehg/hgqt/graft.py
+++ b/tortoisehg/hgqt/graft.py
@@ -234,7 +234,7 @@
def graftstate(self) -> Optional[List[bytes]]:
return hglib.readgraftstate(self.repo)
- def _runCommand(self, cmdline: List[Text]) -> cmdcore.CmdSession:
+ def _runCommand(self, cmdline: List[str]) -> cmdcore.CmdSession:
assert self._cmdsession.isFinished()
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self._stbar.clearProgress)
@@ -298,7 +298,7 @@
self.abortbtn.setEnabled(False)
return False
- def linkActivated(self, cmd: Text) -> None:
+ def linkActivated(self, cmd: str) -> None:
if cmd == 'resolve':
dlg = resolve.ResolveDialog(self._repoagent, self)
dlg.exec()
diff --git a/tortoisehg/hgqt/hgconfig.py b/tortoisehg/hgqt/hgconfig.py
--- a/tortoisehg/hgqt/hgconfig.py
+++ b/tortoisehg/hgqt/hgconfig.py
@@ -50,25 +50,25 @@
return self._ui
def configBool(self,
- section: Text,
- name: Text,
+ section: str,
+ name: str,
default: bool = UNSET_DEFAULT) -> bool:
data = self._ui.configbool(hglib.fromunicode(section), hglib.fromunicode(name),
default=default)
return bool(data)
def configInt(self,
- section: Text,
- name: Text,
+ section: str,
+ name: str,
default: int = UNSET_DEFAULT) -> int:
data = self._ui.configint(hglib.fromunicode(section), hglib.fromunicode(name),
default=default)
return int(data)
def configString(self,
- section: Text,
- name: Text,
- default: Text = UNSET_DEFAULT) -> Text:
+ section: str,
+ name: str,
+ default: str = UNSET_DEFAULT) -> str:
if default is not UNSET_DEFAULT:
default = hglib.fromunicode(default)
data = self._ui.config(hglib.fromunicode(section), hglib.fromunicode(name),
@@ -78,20 +78,20 @@
return hglib.tounicode(data)
def configStringList(self,
- section: Text,
- name: Text,
- default: List[Text] = UNSET_DEFAULT) -> List[Text]:
+ section: str,
+ name: str,
+ default: List[str] = UNSET_DEFAULT) -> List[str]:
if default is not UNSET_DEFAULT:
default = pycompat.maplist(hglib.fromunicode, default)
data = self._ui.configlist(hglib.fromunicode(section), hglib.fromunicode(name),
default=default)
return hglib.to_unicode_list(data)
- def configStringItems(self, section: Text) -> List[Tuple[Text, Text]]:
+ def configStringItems(self, section: str) -> List[Tuple[str, str]]:
"""Returns a list of string (key, value) pairs under the specified
section"""
items = self._ui.configitems(hglib.fromunicode(section))
return [(hglib.tounicode(k), hglib.tounicode(v)) for k, v in items]
- def hasConfig(self, section: Text, name: Text) -> bool:
+ def hasConfig(self, section: str, name: str) -> bool:
return self._ui.hasconfig(hglib.fromunicode(section), hglib.fromunicode(name))
diff --git a/tortoisehg/hgqt/hginit.py b/tortoisehg/hgqt/hginit.py
--- a/tortoisehg/hgqt/hginit.py
+++ b/tortoisehg/hgqt/hginit.py
@@ -52,7 +52,7 @@
def __init__(self,
ui: uimod.ui,
cmdagent: cmdcore.CmdAgent,
- destdir: Text = '.',
+ destdir: str = '.',
parent: Optional[QWidget] = None) -> None:
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
@@ -112,10 +112,10 @@
if path:
self._dest_edit.setText(path)
- def destination(self) -> Text:
+ def destination(self) -> str:
return self._dest_edit.text().strip()
- def _buildCommand(self) -> List[Text]:
+ def _buildCommand(self) -> List[str]:
cfgs = []
if self._add_files_chk.isChecked():
cfgs.append('hooks.post-init.thgskel='
@@ -144,7 +144,7 @@
def __init__(self,
ui: uimod.ui,
- destdir: Text = '.',
+ destdir: str = '.',
parent: Optional[QWidget] = None) -> None:
super().__init__(parent)
self.setWindowTitle(_('New Repository'))
@@ -156,7 +156,7 @@
self.setCommandWidget(InitWidget(ui, cmdagent, destdir, self))
self.commandFinished.connect(self._handleNewRepo)
- def destination(self) -> Text:
+ def destination(self) -> str:
return self.commandWidget().destination()
@pyqtSlot(int)
diff --git a/tortoisehg/hgqt/locktool.py b/tortoisehg/hgqt/locktool.py
--- a/tortoisehg/hgqt/locktool.py
+++ b/tortoisehg/hgqt/locktool.py
@@ -147,7 +147,7 @@
self.refillModel()
self.reload()
- def refillModel(self) -> Dict[Text, List[Text]]:
+ def refillModel(self) -> Dict[str, List[str]]:
# this code is specific to simplelock
locks: Dict[bytes, List[bytes]] = self.sl.parseLocks(self.repo)
lockables: List[bytes] = self.sl.readlockables(self.repo)
@@ -196,11 +196,11 @@
self.showMessage.emit(_('Locking %s') % wfile)
self.lockrun(['lock', wfile])
- def unlock(self, wfile: Text) -> None:
+ def unlock(self, wfile: str) -> None:
self.showMessage.emit(_('Unlocking %s') % wfile)
self.lockrun(['unlock', wfile])
- def lock(self, wfile: Text, user: Text) -> None:
+ def lock(self, wfile: str, user: str) -> None:
self.showMessage.emit(_('Locking %s') % wfile)
self.lockrun(['lock', wfile])
@@ -210,7 +210,7 @@
self.showMessage.emit(_('Refreshing locks...'))
self.lockrun(['locks']) # has side-effect of refreshing locks
- def lockrun(self, ucmdline: List[Text]) -> None:
+ def lockrun(self, ucmdline: List[str]) -> None:
self.operation = ucmdline + [None]
self._cmdsession = sess = self._repoagent.runCommand(ucmdline, self)
sess.commandFinished.connect(self.operationComplete)
diff --git a/tortoisehg/hgqt/manifestmodel.py b/tortoisehg/hgqt/manifestmodel.py
--- a/tortoisehg/hgqt/manifestmodel.py
+++ b/tortoisehg/hgqt/manifestmodel.py
@@ -98,8 +98,8 @@
FirstParent = -2
SecondParent = -3
- def __init__(self, repoagent: RepoAgent, parent: Optional[QObject] = None, rev: Optional[int] = None, namefilter: Optional[Text] = None,
- statusfilter: Text = 'MASC', flat: bool = False) -> None:
+ def __init__(self, repoagent: RepoAgent, parent: Optional[QObject] = None, rev: Optional[int] = None, namefilter: Optional[str] = None,
+ statusfilter: str = 'MASC', flat: bool = False) -> None:
QAbstractItemModel.__init__(self, parent)
self._fileiconprovider = QFileIconProvider()
@@ -131,7 +131,7 @@
if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole):
return
e.name
- def filePath(self, index: QModelIndex) -> Text:
+ def filePath(self, index: QModelIndex) -> str:
"""Return path at the given index [unicode]"""
if not index.isValid():
return ''
@@ -159,7 +159,7 @@
return filedata.createDirData(e.ctx, e.pctx, wfile, rpath)
return filedata.createFileData(e.ctx, e.pctx, wfile, f.status, rpath)
- def subrepoType(self, index: QModelIndex) -> Optional[Text]:
+ def subrepoType(self, index: QModelIndex) -> Optional[str]:
"""Return the subrepo type the specified index"""
if not index.isValid():
return
@@ -203,7 +203,7 @@
return ic
- def fileStatus(self, index: QModelIndex) -> Optional[Text]:
+ def fileStatus(self, index: QModelIndex) -> Optional[str]:
"""Return the change status of the specified file"""
if not index.isValid():
return
@@ -214,7 +214,7 @@
return e.status
# TODO: this should be merged to fileStatus()
- def subrepoStatus(self, index: QModelIndex) -> Optional[Text]:
+ def subrepoStatus(self, index: QModelIndex) -> Optional[str]:
"""Return the change status of the specified subrepo"""
if not index.isValid():
return
@@ -245,7 +245,7 @@
m.setUrls([QUrl.fromLocalFile(os.path.join(base, e)) for e in files])
return m
- def mimeTypes(self) -> List[Text]:
+ def mimeTypes(self) -> List[str]:
return ['text/uri-list']
def flags(self, index: QModelIndex) -> Qt_ItemFlags:
@@ -265,7 +265,7 @@
return QModelIndex()
return self.createIndex(row, column, self._parententry(parent).at(row))
- def indexFromPath(self, path: Text, column: int = 0) -> QModelIndex:
+ def indexFromPath(self, path: str, column: int = 0) -> QModelIndex:
"""Return index for the specified path if found [unicode]
If not found, returns invalid index.
@@ -354,25 +354,25 @@
if self._rootpopulated:
self.revLoaded.emit(self.rev())
- def nameFilter(self) -> Text:
+ def nameFilter(self) -> str:
"""Return the current name filter"""
return self._namefilter
@pyqtSlot(str)
- def setNameFilter(self, pattern: Text) -> None:
+ def setNameFilter(self, pattern: str) -> None:
"""Filter file name by partial match of glob pattern"""
if self._namefilter == pattern:
return
self._namefilter = pattern
self._repopulateNodes()
- def statusFilter(self) -> Text:
+ def statusFilter(self) -> str:
"""Return the current status filter"""
return self._statusfilter
# TODO: split or remove 'S' which causes several design flaws
@pyqtSlot(str)
- def setStatusFilter(self, status: Text) -> None:
+ def setStatusFilter(self, status: str) -> None:
"""Filter file tree by change status 'MARSC'"""
assert all(c in 'MARSC' for c in status), repr(status)
if self._statusfilter == status:
@@ -489,17 +489,17 @@
__slots__ = ('_name', '_parent', 'status', 'ctx', 'pctx', 'subkind',
'_child', '_nameindex')
- _name: Text
+ _name: str
_parent: Optional[_Entry]
- status: Optional[Text]
+ status: Optional[str]
ctx: Optional[ThgContext]
pctx: Optional[ThgContext]
- subkind: Optional[Text]
- _child: Dict[Text, _Entry]
- _nameindex: List[Text]
+ subkind: Optional[str]
+ _child: Dict[str, _Entry]
+ _nameindex: List[str]
def __init__(self,
- name: Text = '',
+ name: str = '',
parent: Optional[_Entry] = None) -> None:
self._name = name
self._parent = parent
@@ -524,14 +524,14 @@
return self._parent
@property
- def path(self) -> Text:
+ def path(self) -> str:
if self.parent is None or not
self.parent.name:
return
self.name
else:
return self.parent.path + '/' +
self.name
@property
- def name(self) -> Text:
+ def name(self) -> str:
return self._name
@property
@@ -547,16 +547,16 @@
__bool__ = __nonzero__
- def __getitem__(self, name: Text) -> _Entry:
+ def __getitem__(self, name: str) -> _Entry:
return self._child[name]
- def makechild(self, name: Text) -> _Entry:
+ def makechild(self, name: str) -> _Entry:
if name not in self._child:
self._nameindex.append(name)
self._child[name] = e = self.__class__(name, parent=self)
return e
- def putchild(self, name: Text, e: _Entry) -> None:
+ def putchild(self, name: str, e: _Entry) -> None:
assert not
e.name and not e.parent, (
e.name, e.parent)
e._name = name
e._parent = self
@@ -564,13 +564,13 @@
self._nameindex.append(name)
self._child[name] = e
- def __contains__(self, item: Text) -> bool:
+ def __contains__(self, item: str) -> bool:
return item in self._child
def at(self, index: int) -> _Entry:
return self._child[self._nameindex[index]]
- def index(self, name: Text) -> int:
+ def index(self, name: str) -> int:
return self._nameindex.index(name)
def sort(self, reverse: bool = False) -> None:
@@ -625,28 +625,28 @@
subreporecursive = False
@staticmethod
- def findpath(e: _Entry, path: Text) -> _Entry:
+ def findpath(e: _Entry, path: str) -> _Entry:
return e[path]
@staticmethod
- def makepath(e: _Entry, path: Text) -> _Entry:
+ def makepath(e: _Entry, path: str) -> _Entry:
return e.makechild(path)
@staticmethod
- def putpath(e: _Entry, path: Text, c: _Entry) -> None:
+ def putpath(e: _Entry, path: str, c: _Entry) -> None:
e.putchild(path, c)
class _treenodeop:
subreporecursive = True
@staticmethod
- def findpath(e: _Entry, path: Text) -> _Entry:
+ def findpath(e: _Entry, path: str) -> _Entry:
for p in path.split('/'):
e = e[p]
return e
@staticmethod
- def makepath(e: _Entry, path: Text) -> _Entry:
+ def makepath(e: _Entry, path: str) -> _Entry:
for p in path.split('/'):
if p not in e:
e.makechild(p)
@@ -654,7 +654,7 @@
return e
@staticmethod
- def putpath(e: _Entry, path: Text, c: _Entry) -> None:
+ def putpath(e: _Entry, path: str, c: _Entry) -> None:
rp = path.rfind('/')
if rp >= 0:
e = _treenodeop.makepath(e, path[:rp])
@@ -669,7 +669,7 @@
def _populaterepo(roote: _Entry,
repo: localrepo.localrepository,
nodeop,
- statusfilter: Text,
+ statusfilter: str,
match: matchmod.basematcher) -> None:
# TODO: replace 'Any' with structural typing for _treenodeop/_listnodeop
if 'S' in statusfilter:
@@ -689,7 +689,7 @@
e.status = st
def _comparesubstate(state1: Tuple[bytes, bytes, bytes],
- state2: Tuple[bytes, bytes, bytes]) -> Text:
+ state2: Tuple[bytes, bytes, bytes]) -> str:
if state1 == state2:
return 'C'
elif state1 == hglib.nullsubrepostate:
@@ -702,7 +702,7 @@
def _populatesubrepos(roote: _Entry,
repo: localrepo.localrepository,
nodeop,
- statusfilter: Text,
+ statusfilter: str,
match: matchmod.basematcher) -> None:
# TODO: replace 'Any' with structural typing for _treenodeop/_listnodeop
ctx = roote.ctx
@@ -747,7 +747,7 @@
def _populatepatch(roote: _Entry,
repo: localrepo.localrepository,
nodeop,
- statusfilter: Text,
+ statusfilter: str,
match: matchmod.basematcher) -> None:
# TODO: replace 'Any' with structural typing for _treenodeop/_listnodeop
ctx = roote.ctx
@@ -765,7 +765,7 @@
class ManifestCompleter(QCompleter):
"""QCompleter for ManifestModel"""
- def splitPath(self, path: Text) -> List[Text]:
+ def splitPath(self, path: str) -> List[str]:
"""
>>> c = ManifestCompleter()
>>> c.splitPath(u'foo/bar')
@@ -778,7 +778,7 @@
"""
return path.split('/')
- def pathFromIndex(self, index: QModelIndex) -> Text:
+ def pathFromIndex(self, index: QModelIndex) -> str:
if not index.isValid():
return ''
m = self.model()
diff --git a/tortoisehg/hgqt/phabreview.py b/tortoisehg/hgqt/phabreview.py
--- a/tortoisehg/hgqt/phabreview.py
+++ b/tortoisehg/hgqt/phabreview.py
@@ -67,27 +67,27 @@
__slots__ = ()
def __new__(cls,
- username: Text,
- realname: Text,
- roles: List[Text]) -> user:
+ username: str,
+ realname: str,
+ roles: List[str]) -> user:
return tuple.__new__(cls, (username, realname, roles))
@property
- def username(self) -> Text:
+ def username(self) -> str:
'''username used by phabsend'''
return self[0]
@property
- def realname(self) -> Text:
+ def realname(self) -> str:
'''friendly name of this user'''
return self[1]
@property
- def roles(self) -> List[Text]:
+ def roles(self) -> List[str]:
'''the roles filled by this user'''
return self[2]
- def __repr__(self) -> Text:
+ def __repr__(self) -> str:
return '%s (%s)' % (self.realname, self.username)
@@ -168,7 +168,7 @@
s.setValue('phabsend/geom', self.saveGeometry())
def _reviewerhistorypath(self,
- withcallsign: bool = False) -> Optional[Text]:
+ withcallsign: bool = False) -> Optional[str]:
'''Fetches the path in the settings used to store reviewer history.
If no reviewers are stored or the configuration isn't present to find
@@ -321,7 +321,7 @@
"""Returns list of revisions to be sent"""
return self._changesets.selectedrevs
- def _phabsendopts(self, **opts) -> Dict[Text, Any]:
+ def _phabsendopts(self, **opts) -> Dict[str, Any]:
"""Generate opts for phabsend by form values"""
opts['rev'] = hglib.compactrevs(self._revs)
diff --git a/tortoisehg/hgqt/pick.py b/tortoisehg/hgqt/pick.py
--- a/tortoisehg/hgqt/pick.py
+++ b/tortoisehg/hgqt/pick.py
@@ -192,7 +192,7 @@
sess = self._runCommand(cmdline)
sess.commandFinished.connect(self._abortFinished)
- def _runCommand(self, cmdline: List[Text]) -> cmdcore.CmdSession:
+ def _runCommand(self, cmdline: List[str]) -> cmdcore.CmdSession:
assert self._cmdsession.isFinished()
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self._stbar.clearProgress)
@@ -247,7 +247,7 @@
self.abortbtn.setEnabled(False)
return False
- def linkActivated(self, cmd: Text) -> None:
+ def linkActivated(self, cmd: str) -> None:
if cmd == 'resolve':
dlg = resolve.ResolveDialog(self._repoagent, self)
dlg.exec()
diff --git a/tortoisehg/hgqt/postreview.py b/tortoisehg/hgqt/postreview.py
--- a/tortoisehg/hgqt/postreview.py
+++ b/tortoisehg/hgqt/postreview.py
@@ -278,19 +278,19 @@
"""Returns list of revisions to be sent"""
return self._changesets.revs
- def getRepoId(self) -> Text:
+ def getRepoId(self) -> str:
comboText = self.qui.repo_id_combo.currentText().split(":")
return comboText[0]
- def getReviewId(self) -> Text:
+ def getReviewId(self) -> str:
comboText = self.qui.review_id_combo.currentText().split(":")
return comboText[0]
- def getSummary(self) -> Text:
+ def getSummary(self) -> str:
comboText = self.qui.review_id_combo.currentText().split(":")
return comboText[1]
- def postReviewOpts(self, **opts) -> Dict[Text, Union[bool, Text]]:
+ def postReviewOpts(self, **opts) -> Dict[str, Union[bool, str]]:
"""Generate opts for reviewboard by form values"""
opts['outgoingchanges'] = self.qui.outgoing_changes_check.isChecked()
opts['branch'] = self.qui.branch_check.isChecked()
@@ -374,7 +374,7 @@
self.qui.progress_label.setText("Posting Review...")
self.qui.progress_label.show()
- def cmdargs(opts: Dict[Text, Union[bool, Text]]) -> List[Text]:
+ def cmdargs(opts: Dict[str, Union[bool, str]]) -> List[str]:
args = []
for k, v in opts.items():
if isinstance(v, bool):
@@ -438,7 +438,7 @@
super().accept()
@pyqtSlot(str, str)
- def _captureOutput(self, msg: Text, label: Text) -> None:
+ def _captureOutput(self, msg: str, label: str) -> None:
if label != 'control':
self._cmdoutputs.append(msg)
diff --git a/tortoisehg/hgqt/prune.py b/tortoisehg/hgqt/prune.py
--- a/tortoisehg/hgqt/prune.py
+++ b/tortoisehg/hgqt/prune.py
@@ -86,10 +86,10 @@
self._revedit.setFocus()
- def revset(self) -> Text:
+ def revset(self) -> str:
return self._revedit.currentText()
- def setRevset(self, revspec: Text) -> None:
+ def setRevset(self, revspec: str) -> None:
if self.revset() == revspec:
return
w = self._revedit
@@ -143,7 +143,7 @@
def createPruneDialog(repoagent: RepoAgent,
- revspec: Text,
+ revspec: str,
parent: Optional[QWidget] = None) -> cmdui.CmdControlDialog:
dlg = cmdui.CmdControlDialog(parent)
dlg.setWindowIcon(qtlib.geticon('edit-cut'))
diff --git a/tortoisehg/hgqt/qtlib.py b/tortoisehg/hgqt/qtlib.py
--- a/tortoisehg/hgqt/qtlib.py
+++ b/tortoisehg/hgqt/qtlib.py
@@ -146,7 +146,7 @@
atexit.register(cleanup)
return tmproot
-def openhelpcontents(url: Text) -> None:
+def openhelpcontents(url: str) -> None:
'Open online help, use local CHM file if available'
if not url.startswith('http'):
fullurl = '
https://tortoisehg.readthedocs.org/en/latest/' + url
@@ -364,7 +364,7 @@
# a) it appears to be broken before PyQt 4.11.x (#4882)
# b) it may raise TypeError if a setting has a value of an unexpected type
-def readBool(qs: QSettings, key: Text, default: bool = False) -> bool:
+def readBool(qs: QSettings, key: str, default: bool = False) -> bool:
"""Read the specified value from QSettings and coerce into bool"""
v = qs.value(key, default)
if hglib.isbasestring(v):
@@ -372,7 +372,7 @@
return not (v == '0' or v == 'false' or v == '')
return bool(v)
-def readByteArray(qs: QSettings, key: Text, default: bytes = b'') -> QByteArray:
+def readByteArray(qs: QSettings, key: str, default: bytes = b'') -> QByteArray:
"""Read the specified value from QSettings and coerce into QByteArray"""
v = qs.value(key, default)
if v is None:
@@ -382,7 +382,7 @@
except TypeError:
return QByteArray(default)
-def readInt(qs: QSettings, key: Text, default: int = 0) -> int:
+def readInt(qs: QSettings, key: str, default: int = 0) -> int:
"""Read the specified value from QSettings and coerce into int"""
v = qs.value(key, default)
if v is None:
@@ -392,7 +392,7 @@
except (TypeError, ValueError):
return int(default)
-def readString(qs: QSettings, key: Text, default: Text = '') -> Text:
+def readString(qs: QSettings, key: str, default: str = '') -> str:
"""Read the specified value from QSettings and coerce into string"""
v = qs.value(key, default)
if v is None:
@@ -404,9 +404,9 @@
def readStringList(
qs: QSettings,
- key: Text,
- default: Iterable[Text] = (),
-) -> List[Text]:
+ key: str,
+ default: Iterable[str] = (),
+) -> List[str]:
"""Read the specified value from QSettings and coerce into string list"""
v = qs.value(key, default)
if v is None:
@@ -491,7 +491,7 @@
# See
https://doc.qt.io/qt-4.8/richtext-html-subset.html
# and
https://www.w3.org/TR/SVG/types.html#ColorKeywords
-def geteffect(labels: Text) -> Text:
+def geteffect(labels: str) -> str:
'map labels like "log.date" to Qt font styles'
effects = []
# Multiple labels may be requested
@@ -512,7 +512,7 @@
effects.append('color: ' + e)
return ';'.join(effects)
-def gettextcoloreffect(labels: Text) -> QColor:
+def gettextcoloreffect(labels: str) -> QColor:
"""Map labels like "log.date" to foreground color if available"""
for l in labels.split():
if not l:
@@ -522,7 +522,7 @@
return QColor(e)
return QColor()
-def getbgcoloreffect(labels: Text) -> QColor:
+def getbgcoloreffect(labels: str) -> QColor:
"""Map labels like "log.date" to background color if available
Returns QColor object. You may need to check validity by isValid().
@@ -550,7 +550,7 @@
'decoration': 'text-decoration',
}
-def markup(msg: AnyStr, **styles: Text) -> Text:
+def markup(msg: AnyStr, **styles: str) -> str:
style = {'white-space': 'pre'}
for name, value in styles.items():
if not value:
@@ -564,7 +564,7 @@
msg = msg.replace('\n', '<br />')
return u'<span style="%s">%s</span>' % (style, msg)
-def descriptionhtmlizer(ui: uimod.ui) -> Callable[[AnyStr], Text]:
+def descriptionhtmlizer(ui: uimod.ui) -> Callable[[AnyStr], str]:
"""Return a function to mark up ctx.description() as an HTML
>>> from mercurial import ui
@@ -631,7 +631,7 @@
except re.error:
pass
- def htmlize(desc: AnyStr) -> Text:
+ def htmlize(desc: AnyStr) -> str:
"""Mark up ctx.description() [localstr] as an HTML [unicode]"""
desc = hglib.tounicode(desc)
@@ -668,24 +668,24 @@
return htmlize
-_iconcache: Dict[Text, QIcon] = {}
+_iconcache: Dict[str, QIcon] = {}
if getattr(sys, 'frozen', False) and
os.name == 'nt':
- def iconpath(f: Text, *insidef: Text) -> Text:
+ def iconpath(f: str, *insidef: str) -> str:
return posixpath.join(':/icons', f, *insidef)
else:
- def iconpath(f: Text, *insidef: Text) -> Text:
+ def iconpath(f: str, *insidef: str) -> str:
return os.path.join(paths.get_icon_path(), f, *insidef)
if hasattr(QIcon, 'hasThemeIcon'): # PyQt>=4.7
- def _findthemeicon(name: Text) -> Optional[QIcon]:
+ def _findthemeicon(name: str) -> Optional[QIcon]:
if QIcon.hasThemeIcon(name):
return QIcon.fromTheme(name)
else:
- def _findthemeicon(name: Text) -> Optional[QIcon]:
+ def _findthemeicon(name: str) -> Optional[QIcon]:
pass
-def _findcustomicon(name: Text) -> Optional[QIcon]:
+def _findcustomicon(name: str) -> Optional[QIcon]:
# let a user set the icon of a custom tool button
if os.path.isabs(name):
path = name
@@ -706,7 +706,7 @@
(QSize(32, 32), '32x32/status', '.png'),
(QSize(24, 24), '24x24/actions', '.png')]
-def getallicons() -> List[Text]:
+def getallicons() -> List[str]:
"""Get a sorted, unique list of all available icons"""
iconset = set()
for size, subdir, sfx in _SCALABLE_ICON_PATHS:
@@ -717,7 +717,7 @@
iconset.add(pycompat.unicode(iconname).rsplit('.', 1)[0])
return sorted(iconset)
-def _findscalableicon(name: Text) -> Optional[QIcon]:
+def _findscalableicon(name: str) -> Optional[QIcon]:
"""Find icon from qrc by using freedesktop-like icon lookup"""
o = QIcon()
for size, subdir, sfx in _SCALABLE_ICON_PATHS:
@@ -728,7 +728,7 @@
if not o.isNull():
return o
-def geticon(name: Text) -> QIcon:
+def geticon(name: str) -> QIcon:
"""
Return a QIcon for the specified name. (the given 'name' parameter
must *not* provide the extension).
@@ -758,9 +758,9 @@
return QIcon(pixmap)
-_pixmapcache: Dict[Text, QPixmap] = {}
+_pixmapcache: Dict[str, QPixmap] = {}
-def getpixmap(name: Text, width: int = 16, height: int = 16) -> QPixmap:
+def getpixmap(name: str, width: int = 16, height: int = 16) -> QPixmap:
key = '%s_%sx%s' % (name, width, height)
try:
return _pixmapcache[key]
@@ -836,7 +836,7 @@
class ThgFont(QObject):
changed = pyqtSignal(QFont)
- def __init__(self, name: Text) -> None:
+ def __init__(self, name: str) -> None:
QObject.__init__(self)
self.myfont = QFont()
self.myfont.fromString(name)
@@ -846,7 +846,7 @@
self.myfont = f
self.changed.emit(f)
-_fontdefaults: Dict[Text, Text] = {
+_fontdefaults: Dict[str, str] = {
'fontcomment': 'monospace,10',
'fontdiff': 'monospace,10',
'fonteditor': 'monospace,10',
@@ -855,7 +855,7 @@
}
if sys.platform == 'darwin':
_fontdefaults['fontoutputlog'] = 'sans,10'
-_fontcache: Dict[Text, ThgFont] = {}
+_fontcache: Dict[str, ThgFont] = {}
def initfontcache(ui: uimod.ui):
for name in _fontdefaults:
@@ -863,17 +863,17 @@
pycompat.sysbytes(_fontdefaults[name]))
_fontcache[name] = ThgFont(hglib.tounicode(fname))
-def getfont(name: Text) -> ThgFont:
+def getfont(name: str) -> ThgFont:
assert name in _fontdefaults, (name, _fontdefaults)
return _fontcache[name]
def CommonMsgBox(
icon: QMessageBox.Icon,
- title: Text,
- main: Text,
- text: Text = '',
+ title: str,
+ main: str,
+ text: str = '',
buttons: Union[QMessageBox.StandardButtons, QMessageBox.StandardButton] = QMessageBox.StandardButton.Ok,
- labels: Optional[Iterable[Tuple[QMessageBox.StandardButton, Text]]] = None,
+ labels: Optional[Iterable[Tuple[QMessageBox.StandardButton, str]]] = None,
parent: Optional[QWidget] = None,
defaultbutton: Optional[Union[QPushButton, QMessageBox.StandardButton]] = None,
) -> int:
@@ -894,16 +894,16 @@
msg.setInformativeText(info)
return msg.exec()
-def InfoMsgBox(*args: Text, **kargs) -> int:
+def InfoMsgBox(*args: str, **kargs) -> int:
return CommonMsgBox(QMessageBox.Icon.Information, *args, **kargs)
-def WarningMsgBox(*args: Text, **kargs) -> int:
+def WarningMsgBox(*args: str, **kargs) -> int:
return CommonMsgBox(QMessageBox.Icon.Warning, *args, **kargs)
-def ErrorMsgBox(*args: Text, **kargs) -> int:
+def ErrorMsgBox(*args: str, **kargs) -> int:
return CommonMsgBox(QMessageBox.Icon.Critical, *args, **kargs)
-def QuestionMsgBox(*args: Text, **kargs) -> bool:
+def QuestionMsgBox(*args: str, **kargs) -> bool:
btn = QMessageBox.StandardButton.Yes |
QMessageBox.StandardButton.No
res = CommonMsgBox(QMessageBox.Icon.Question, buttons=btn, *args, **kargs)
return res == QMessageBox.StandardButton.Yes
@@ -914,10 +914,10 @@
title: AnyStr,
message: AnyStr,
parent: Optional[QWidget],
- choices: Iterable[Text],
+ choices: Iterable[str],
default: Optional[int] = None,
esc: Optional[int] = None,
- files: Optional[Iterable[Union[bytes, Text]]] = None,
+ files: Optional[Iterable[Union[bytes, str]]] = None,
) -> None:
# Note: `files` is typed as `Union[bytes, str]` instead of `AnyStr`
# because the latter is defined with TypeVar, and that would enforce
@@ -958,11 +958,11 @@
class ChoicePrompt(QDialog):
def __init__(self,
- title: Text,
- message: Text,
+ title: str,
+ message: str,
parent: QWidget,
- choices: List[Text],
- default: Optional[Text] = None) -> None:
+ choices: List[str],
+ default: Optional[str] = None) -> None:
QDialog.__init__(self, parent)
self.setWindowTitle(title)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)
@@ -997,7 +997,7 @@
self.box.addLayout(vbox)
self.setLayout(self.box)
- def run(self) -> Optional[Text]:
+ def run(self) -> Optional[str]:
if self.exec():
return self.choices[self.choice_combo.currentIndex()]
return None
@@ -1140,7 +1140,7 @@
def __init__(
self,
- label: Text,
+ label: str,
parent: Optional[QWidget] = None,
):
QLabel.__init__(self, parent)
@@ -1156,7 +1156,7 @@
def __init__(
self,
- label: Text,
+ label: str,
expanded: bool = True,
stretch: bool = True,
parent: Optional[QWidget] = None,
@@ -1210,8 +1210,8 @@
def set_status(
self,
- text: Text,
- icon: Optional[Union[bool, Text, QIcon]] = None,
+ text: str,
+ icon: Optional[Union[bool, str, QIcon]] = None,
) -> None:
self.set_text(text)
self.set_icon(icon)
@@ -1220,7 +1220,7 @@
self.clear_text()
self.clear_icon()
- def set_text(self, text: Optional[Text] = '') -> None:
+ def set_text(self, text: Optional[str] = '') -> None:
if text is None:
text = ''
self.status_text.setText(text)
@@ -1228,7 +1228,7 @@
def clear_text(self) -> None:
self.set_text()
- def set_icon(self, icon: Optional[Union[bool, Text, QIcon]] = None) -> None:
+ def set_icon(self, icon: Optional[Union[bool, str, QIcon]] = None) -> None:
if icon is None:
self.clear_icon()
else:
@@ -1248,7 +1248,7 @@
def __init__(
self,
- label: Optional[Union[QLabel, Text]] = None,
+ label: Optional[Union[QLabel, str]] = None,
parent: Optional[QWidget] = None,
) -> None:
QWidget.__init__(self, parent)
@@ -1276,27 +1276,27 @@
object.__init__(self)
# help pytype by forward declaring
- self.groups: Dict[Text, List[QWidget]] = {}
+ self.groups: Dict[str, List[QWidget]] = {}
self.clear(all=True)
### Public Methods ###
- def add(self, widget: QWidget, group: Text = 'default') -> None:
+ def add(self, widget: QWidget, group: str = 'default') -> None:
if group not in self.groups:
self.groups[group] = []
widgets = self.groups[group]
if widget not in widgets:
widgets.append(widget)
- def remove(self, widget: QWidget, group: Text = 'default') -> None:
+ def remove(self, widget: QWidget, group: str = 'default') -> None:
if group not in self.groups:
return
widgets = self.groups[group]
if widget in widgets:
widgets.remove(widget)
- def clear(self, group: Text = 'default', all: bool = True) -> None:
+ def clear(self, group: str = 'default', all: bool = True) -> None:
if all:
self.groups = {}
else:
@@ -1304,9 +1304,9 @@
def set_prop(
self,
- prop: Text,
+ prop: str,
value: object,
- group: Text = 'default',
+ group: str = 'default',
cond: Optional[Callable[[QWidget], bool]] = None,
) -> None:
if group not in self.groups:
@@ -1462,7 +1462,7 @@
def __init__(
self,
- createfuncname: Text,
+ createfuncname: str,
createinst: object,
parent: Optional[QWidget] = None,
) -> None:
@@ -1482,7 +1482,7 @@
self.get()
super().showEvent(event)
- def forward(self, funcname: Text, *args, **opts) -> Optional[Any]:
+ def forward(self, funcname: str, *args, **opts) -> Optional[Any]:
if self._widget:
return getattr(self._widget, funcname)(*args, **opts)
return None
@@ -1506,7 +1506,7 @@
return True
return self._widget.canExit()
- def __getattr__(self, name: Text) -> Any:
+ def __getattr__(self, name: str) -> Any:
return getattr(self._widget, name)
class Spacer(QWidget):
@@ -1527,7 +1527,7 @@
def getCurrentUsername(widget: Optional[QWidget],
repo: localrepo.localrepository,
- opts: Optional[Dict[Text, Text]] = None) -> Optional[Text]:
+ opts: Optional[Dict[str, str]] = None) -> Optional[str]:
if opts:
# 1. Override has highest priority
user = opts.get('user')
@@ -1561,12 +1561,12 @@
def getTextInput(
parent: Optional[QWidget],
- title: Text,
- label: Text,
+ title: str,
+ label: str,
mode: QLineEdit.EchoMode = QLineEdit.EchoMode.Normal,
- text: Text = '',
+ text: str = '',
flags: Union[Qt.WindowType, Qt.WindowFlags] = Qt.WindowType.Widget,
-) -> Tuple[Text, bool]:
+) -> Tuple[str, bool]:
flags |= (Qt.WindowType.CustomizeWindowHint | Qt.WindowType.WindowTitleHint
| Qt.WindowType.WindowCloseButtonHint)
dlg = _EncodingSafeInputDialog(parent, flags)
@@ -1580,7 +1580,7 @@
return r and dlg.textValue() or '', bool(r)
def keysequence(
- o: Union[QKeySequence, QKeySequence.StandardKey, Text, int],
+ o: Union[QKeySequence, QKeySequence.StandardKey, str, int],
) -> Union[QKeySequence, QKeySequence.StandardKey]:
"""Create QKeySequence from string or QKeySequence"""
if isinstance(o, (QKeySequence, QKeySequence.StandardKey)):
diff --git a/tortoisehg/hgqt/rebase.py b/tortoisehg/hgqt/rebase.py
--- a/tortoisehg/hgqt/rebase.py
+++ b/tortoisehg/hgqt/rebase.py
@@ -260,7 +260,7 @@
sess = self._runCommand(cmdline)
sess.commandFinished.connect(self._abortFinished)
- def _runCommand(self, cmdline: List[Text]) -> cmdcore.CmdSession:
+ def _runCommand(self, cmdline: List[str]) -> cmdcore.CmdSession:
assert self._cmdsession.isFinished()
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self._stbar.clearProgress)
@@ -314,7 +314,7 @@
self.abortbtn.setEnabled(False)
return False
- def linkActivated(self, cmd: Text) -> None:
+ def linkActivated(self, cmd: str) -> None:
if cmd == 'resolve':
dlg = resolve.ResolveDialog(self._repoagent, self)
dlg.exec()
diff --git a/tortoisehg/hgqt/rename.py b/tortoisehg/hgqt/rename.py
--- a/tortoisehg/hgqt/rename.py
+++ b/tortoisehg/hgqt/rename.py
@@ -50,7 +50,7 @@
class RenameWidget(cmdui.AbstractCmdWidget):
- def __init__(self, repoagent: RepoAgent, parent: Optional[QWidget] = None, source: Optional[Text] = None, destination: Optional[Text] = None,
+ def __init__(self, repoagent: RepoAgent, parent: Optional[QWidget] = None, source: Optional[str] = None, destination: Optional[str] = None,
iscopy: bool = False) -> None:
super().__init__(parent)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
@@ -114,17 +114,17 @@
def repo(self):
return self._repoagent.rawRepo()
- def source(self) -> Text:
+ def source(self) -> str:
return self.src_txt.text()
- def destination(self) -> Text:
+ def destination(self) -> str:
return self.dest_txt.text()
- def _sourceFile(self) -> Text:
+ def _sourceFile(self) -> str:
root = self._repoagent.rootPath()
return os.path.normpath(os.path.join(root, self.source()))
- def _destinationFile(self) -> Text:
+ def _destinationFile(self) -> str:
root = self._repoagent.rootPath()
return os.path.normpath(os.path.join(root, self.destination()))
@@ -161,7 +161,7 @@
return
self.dest_txt.setText(relpath)
- def to_relative_path(self, fullpath: Text) -> Optional[Text]:
+ def to_relative_path(self, fullpath: str) -> Optional[str]:
if not fullpath:
return
fullpath = hglib.normpath(fullpath)
@@ -182,12 +182,12 @@
fullsrc, fulldest = self._sourceFile(), self._destinationFile()
return fullsrc.upper() == fulldest.upper() and sys.platform == 'win32'
- def compose_command(self) -> List[Text]:
+ def compose_command(self) -> List[str]:
name = self.isCopyCommand() and 'copy' or 'rename'
return hglib.buildcmdargs(name, self.source(), self.destination(),
v=True, f=True)
- def show_command(self, cmdline: List[Text]) -> None:
+ def show_command(self, cmdline: List[str]) -> None:
self.hgcmd_txt.setText('hg %s' % hglib.prettifycmdline(cmdline))
def canRunCommand(self) -> bool:
@@ -225,7 +225,7 @@
class RenameDialog(cmdui.CmdControlDialog):
- def __init__(self, repoagent: RepoAgent, parent: Optional[QWidget] = None, source: Optional[Text] = None, destination: Optional[Text] = None,
+ def __init__(self, repoagent: RepoAgent, parent: Optional[QWidget] = None, source: Optional[str] = None, destination: Optional[str] = None,
iscopy: bool = False) -> None:
super().__init__(parent)
self._repoagent = repoagent
diff --git a/tortoisehg/hgqt/repofilter.py b/tortoisehg/hgqt/repofilter.py
--- a/tortoisehg/hgqt/repofilter.py
+++ b/tortoisehg/hgqt/repofilter.py
@@ -69,7 +69,7 @@
'tagged()', 'bookmark()',
'file(".hgsubstate") or file(".hgsub")')
-def _firstword(query: Text) -> Optional[bytes]:
+def _firstword(query: str) -> Optional[bytes]:
lquery = hglib.fromunicode(query)
try:
for token, value, _pos in hglib.tokenizerevspec(lquery):
@@ -78,7 +78,7 @@
except error.ParseError:
pass
-def _querytype(repo: localrepo.localrepository, query: Text) -> Optional[Text]:
+def _querytype(repo: localrepo.localrepository, query: str) -> Optional[str]:
r"""
>>> # TODO: maybe replace with real repo
>>> origisrevsymbol = scmutil.isrevsymbol
@@ -302,11 +302,11 @@
self.entrydlg.entry.setFocus()
self.entrydlg.setVisible(True)
- def queryIssued(self, query: Text) -> None:
+ def queryIssued(self, query: str) -> None:
self.revsetcombo.setEditText(query)
self.runQuery()
- def _prepareQuery(self) -> Text:
+ def _prepareQuery(self) -> str:
query = self.revsetcombo.currentText().strip()
if _querytype(self._repo, query) == 'keyword':
return hglib.formatrevspec('keyword(%s)', query)
@@ -352,7 +352,7 @@
margins.setRight(w + 1)
le.setContentsMargins(margins)
- def setQuery(self, query: Text) -> None:
+ def setQuery(self, query: str) -> None:
self.revsetcombo.setCurrentIndex(self.revsetcombo.findText(query))
self.revsetcombo.setEditText(query)
@@ -500,13 +500,13 @@
self._emitBranchChanged() # falls back to "show all"
@pyqtSlot(str)
- def setBranch(self, branch: Text) -> None:
+ def setBranch(self, branch: str) -> None:
"""Change the current branch by name [unicode]"""
index = self._branchCombo.findData(branch)
if index >= 0:
self._branchCombo.setCurrentIndex(index)
- def branch(self) -> Text:
+ def branch(self) -> str:
"""Return the current branch name [unicode]"""
index = self._branchCombo.currentIndex()
branch = self._branchCombo.itemData(index)
diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py
+++ b/tortoisehg/hgqt/repomodel.py
@@ -127,7 +127,7 @@
GraphNodeRole = Qt.ItemDataRole.UserRole + 0
LabelsRole = Qt.ItemDataRole.UserRole + 1 # [(text, style), ...]
-def _parsebranchcolors(value: Text) -> List[Tuple[Text, Text]]:
+def _parsebranchcolors(value: str) -> List[Tuple[str, str]]:
r"""Parse tortoisehg.branchcolors setting
>>> _parsebranchcolors('foo:#123456 bar:#789abc ')
@@ -232,7 +232,7 @@
self._branch_colors.update(_parsebranchcolors(
self._repoagent.configString('tortoisehg', 'branchcolors')))
- def setBranch(self, branch: Text, allparents: bool = False) -> None:
+ def setBranch(self, branch: str, allparents: bool = False) -> None:
branchchanged = (branch != self._filterbranch)
parentchanged = (allparents != self._allparents)
self._filterbranch = branch
@@ -348,10 +348,10 @@
self._emitAllDataChanged()
self.revsUpdated.emit()
- def revset(self) -> Text:
+ def revset(self) -> str:
return self._revspec
- def setRevset(self, revspec: Text) -> None:
+ def setRevset(self, revspec: str) -> None:
if revspec == self._revspec:
return
self._revspec = revspec
@@ -425,7 +425,7 @@
bottomright = self.index(self._rowcount - 1, self.columnCount() - 1)
self.dataChanged.emit(self.index(0, 0), bottomright)
- def branch(self) -> Text:
+ def branch(self) -> str:
return self._filterbranch
def canFetchMore(self, parent: QModelIndex) -> bool:
@@ -489,7 +489,7 @@
return 0
return len(self.allColumns())
- def maxWidthValueForColumn(self, column: int) -> Optional[Text]:
+ def maxWidthValueForColumn(self, column: int) -> Optional[str]:
if column == RevColumn:
return '8' * len(str(len(self.repo))) + '+'
if column in (NodeColumn, GitNodeColumn):
@@ -523,14 +523,14 @@
return -1
return gnode.rev
- def _user_color(self, user: Text) -> Text:
+ def _user_color(self, user: str) -> str:
'deprecated, please replace with hgtk color scheme'
if user not in self._user_colors:
idx = graph.hashcolor(user)
self._user_colors[user] = graph.COLORS[idx]
return self._user_colors[user]
- def _namedbranch_color(self, branch: Text) -> Text:
+ def _namedbranch_color(self, branch: str) -> str:
'deprecated, please replace with hgtk color scheme'
if branch not in self._branch_colors:
idx = graph.hashcolor(branch)
@@ -655,7 +655,7 @@
or (self._revspec and not self._selectedrevs
and not self._querysess.isFinished()))
- def mimeTypes(self) -> List[Text]:
+ def mimeTypes(self) -> List[str]:
return [mqpatchmimetype]
def supportedDropActions(self):
@@ -704,7 +704,7 @@
def headerData(self,
section: int,
orientation: int,
- role: int = Qt.ItemDataRole.DisplayRole) -> Optional[Text]:
+ role: int = Qt.ItemDataRole.DisplayRole) -> Optional[str]:
if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:
return self.allColumnHeaders()[section][1]
@@ -746,7 +746,7 @@
return QModelIndex()
return self.index(row, 0)
- def _getbranch(self, ctx: context.changectx) -> Text:
+ def _getbranch(self, ctx: context.changectx) -> str:
b = hglib.tounicode(ctx.branch())
assert b is not None
if ctx.extra().get(b'close'):
@@ -756,7 +756,7 @@
b += u'--'
return b
- def _getlatesttags(self, ctx: context.changectx) -> Text:
+ def _getlatesttags(self, ctx: context.changectx) -> str:
rev = ctx.rev()
todo = [rev]
repo = self.repo
@@ -786,13 +786,13 @@
self._latesttags[rev] = pdate, pdist + 1, ptag
return self._latesttags[rev][2]
- def _gettags(self, ctx: context.changectx) -> Text:
+ def _gettags(self, ctx: context.changectx) -> str:
if ctx.rev() is None:
return ''
tags = [hglib.tounicode(t) for t in ctx.tags() if t not in self._mqtags]
return ','.join(tags)
- def _getrev(self, ctx: context.changectx) -> Text:
+ def _getrev(self, ctx: context.changectx) -> str:
rev = ctx.rev()
if isinstance(rev, int):
return str(rev)
@@ -801,7 +801,7 @@
else:
return ''
- def _getauthor(self, ctx: context.changectx) -> Text:
+ def _getauthor(self, ctx: context.changectx) -> str:
try:
user = ctx.user()
if not self._fullauthorname:
@@ -810,7 +810,7 @@
except error.Abort:
return _('Mercurial User')
- def _getlog(self, ctx: context.changectx) -> Text:
+ def _getlog(self, ctx: context.changectx) -> str:
if ctx.rev() is None:
if self.unicodestar:
# The Unicode symbol is a black star:
@@ -823,7 +823,7 @@
limit = None # first line
return hglib.longsummary(ctx.description(), limit)
- def _getrevlabels(self, ctx: context.changectx) -> List[Tuple[Text, Text]]:
+ def _getrevlabels(self, ctx: context.changectx) -> List[Tuple[str, str]]:
labels = []
# as of hg 4.4.2, repo.branchheads() can be slow because of
@@ -880,7 +880,7 @@
return labels
- def _getchanges(self, ctx: context.changectx) -> List[Tuple[Text, Text]]:
+ def _getchanges(self, ctx: context.changectx) -> List[Tuple[str, str]]:
"""Return the MAR status for the given ctx."""
labels = []
@@ -894,7 +894,7 @@
labels.append((str(len(R)), 'log.removed'))
return labels
- def _getconv(self, ctx: context.changectx) -> Text:
+ def _getconv(self, ctx: context.changectx) -> str:
if ctx.rev() is not None:
extra = ctx.extra()
cvt = extra.get(b'convert_revision', b'')
@@ -912,7 +912,7 @@
return hglib.tounicode(cvt)
return ''
- def _getphase(self, ctx: context.changectx) -> Text:
+ def _getphase(self, ctx: context.changectx) -> str:
if ctx.rev() is None:
return ''
try:
@@ -920,13 +920,13 @@
except:
return 'draft'
- def _gettopic(self, ctx: context.changectx) -> Optional[Text]:
+ def _gettopic(self, ctx: context.changectx) -> Optional[str]:
return hglib.tounicode(ctx.extra().get(b'topic'))
def _hasFileColumn(self) -> bool:
return False # no FileColumn
- def allColumns(self) -> Tuple[Text, ...]:
+ def allColumns(self) -> Tuple[str, ...]:
if self._hasFileColumn():
return ALLCOLUMNS
else:
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -163,7 +163,7 @@
_SELECTION_ISTRUE = 'istrue'
_SELECTION_ISDRAFTORWD = 'isdraftorwd'
-_KNOWN_SELECTION_ATTRS: Set[Text] = {
+_KNOWN_SELECTION_ATTRS: Set[str] = {
_SELECTION_SINGLE,
_SELECTION_PAIR,
_SELECTION_SOME,
@@ -187,7 +187,7 @@
}
# selection attributes which may be specified by user
-_CUSTOM_TOOLS_SELECTION_ATTRS: Set[Text] = {
+_CUSTOM_TOOLS_SELECTION_ATTRS: Set[str] = {
_SELECTION_ISREV,
_SELECTION_ISWD,
_SELECTION_ISCTX,
@@ -220,7 +220,7 @@
repoLinkClicked = pyqtSignal(str)
"""Emitted when clicked a link to open repository"""
- _actions: Dict[Text, Tuple[QAction, Set[Text], Set[Text]]]
+ _actions: Dict[str, Tuple[QAction, Set[str], Set[str]]]
def __init__(self, actionregistry, repoagent, parent=None, bundle=None):
QWidget.__init__(self, parent, acceptDrops=True)
@@ -1197,7 +1197,7 @@
return (len(self.repoview.selectedRevisions()) == 2
and not self._isUnappliedPatchSelected())
- def _selectionAttributes(self) -> Set[Text]:
+ def _selectionAttributes(self) -> Set[str]:
"""Returns a set of keywords that describe the selected revisions"""
attributes = {_SELECTION_ISTRUE}
@@ -1265,7 +1265,7 @@
return attributes
- def _selectedIntRevisionsAndUnappliedPatches(self) -> Tuple[List[int], List[Text]]:
+ def _selectedIntRevisionsAndUnappliedPatches(self) -> Tuple[List[int], List[str]]:
"""Returns lists of selected change/workingctx revisions and unapplied
patches"""
revisions = []
@@ -1312,7 +1312,7 @@
# simply disable lazy evaluation as we won't handle slow query
return list(self.repo.revs(b'%d::%d', rev0, rev1))
- def _selectedUnappliedPatches(self) -> List[Text]:
+ def _selectedUnappliedPatches(self) -> List[str]:
"""Returns a list of selected unapplied patches"""
_revisions, patches = self._selectedIntRevisionsAndUnappliedPatches()
return patches
@@ -1512,10 +1512,10 @@
menu.popup(point)
def _createNamedAction(self,
- name: Text,
- attrs: Set[Text],
- exts: Optional[Set[Text]] = None,
- icon: Optional[Text] = None,
+ name: str,
+ attrs: Set[str],
+ exts: Optional[Set[str]] = None,
+ icon: Optional[str] = None,
cb: Optional[Callable] = None) -> QAction:
act = QAction(self)
act.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
@@ -1527,10 +1527,10 @@
return act
def _addNamedAction(self,
- name: Text,
+ name: str,
act: QAction,
- attrs: Set[Text],
- exts: Optional[Set[Text]] = None) -> None:
+ attrs: Set[str],
+ exts: Optional[Set[str]] = None) -> None:
assert name not in self._actions, name
assert attrs.issubset(_KNOWN_SELECTION_ATTRS), attrs
# RepoWidget actions act on revisions selected in the graph view, so
@@ -1544,7 +1544,7 @@
def _addNamedActionsToMenu(self,
menu: QMenu,
- names: List[Optional[Text]]) -> None:
+ names: List[Optional[str]]) -> None:
for n in names:
if n:
menu.addAction(self._actions[n][0])
@@ -1559,7 +1559,7 @@
act.setEnabled(attrs.issubset(selattrs))
act.setVisible(not exts or bool(exts & enabledexts))
- def _addCustomToolsSubMenu(self, menu: QMenu, location: Text) -> None:
+ def _addCustomToolsSubMenu(self, menu: QMenu, location: str) -> None:
tools, toollist = hglib.tortoisehgtools(self.repo.ui,
selectedlocation=location)
@@ -2450,8 +2450,8 @@
"""Make REV the top applied patch"""
self._qpushRevision(move=True)
- def runCustomCommand(self, command: Text, showoutput: bool = False, workingdir: Text = '',
- files: Optional[List[Text]] = None) -> Optional[Union[int, subprocess.Popen]]:
+ def runCustomCommand(self, command: str, showoutput: bool = False, workingdir: str = '',
+ files: Optional[List[str]] = None) -> Optional[Union[int, subprocess.Popen]]:
"""Execute 'custom commands', on the selected repository"""
# Perform variable expansion
# This is done in two steps:
@@ -2466,7 +2466,7 @@
workingdir = os.path.expandvars(workingdir).strip()
# 2. Expand internal workbench variables
- def filelist2str(filelist: List[Text]) -> Text:
+ def filelist2str(filelist: List[str]) -> str:
return hglib.tounicode(b' '.join(
procutil.shellquote(
os.path.normpath(self.repo.wjoin(hglib.fromunicode(filename))))
@@ -2478,7 +2478,7 @@
selection = self.repoview.selectedRevisions()
- def selectionfiles2str(source: Text) -> Text:
+ def selectionfiles2str(source: str) -> str:
files = set()
for rev in selection:
files.update(
diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -278,7 +278,7 @@
paths.append((root, wfile))
return paths
- def runCommand(self, tree: QTreeView, cmdline: List[Text]) -> None:
+ def runCommand(self, tree: QTreeView, cmdline: List[str]) -> None:
cmdlines = []
selected = self.getSelectedPaths(tree)
while selected:
@@ -524,7 +524,7 @@
def data(self,
index: QModelIndex,
- role: int = Qt.ItemDataRole.DisplayRole) -> Optional[Text]:
+ role: int = Qt.ItemDataRole.DisplayRole) -> Optional[str]:
if not index.isValid():
return None
if role == Qt.ItemDataRole.DisplayRole:
@@ -542,7 +542,7 @@
def headerData(self,
col: int,
orientation: int,
- role: int = Qt.ItemDataRole.DisplayRole) -> Optional[Text]:
+ role: int = Qt.ItemDataRole.DisplayRole) -> Optional[str]:
if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
@@ -553,7 +553,7 @@
row = index.row()
return self.rows[row][2], self.rows[row][0]
- def mimeTypes(self) -> List[Text]:
+ def mimeTypes(self) -> List[str]:
return ['text/uri-list']
def mimeData(self, indexes: List[QModelIndex]) -> QMimeData:
diff --git a/tortoisehg/hgqt/serve.py b/tortoisehg/hgqt/serve.py
--- a/tortoisehg/hgqt/serve.py
+++ b/tortoisehg/hgqt/serve.py
@@ -121,7 +121,7 @@
self._agent.runCommand(self._cmdargs())
- def _cmdargs(self) -> List[Text]:
+ def _cmdargs(self) -> List[str]:
"""Build command args to run server"""
a = ['serve', '--port', str(self.port), '-v']
if self._singlerepo:
@@ -130,7 +130,7 @@
a += ['--web-conf', self._tempwebconf()]
return a
- def _tempwebconf(self) -> Text:
+ def _tempwebconf(self) -> str:
"""Save current webconf to temporary file; return its path"""
webconf = self._webconf
if not hasattr(webconf, 'write'):
@@ -153,7 +153,7 @@
return self._webconf_form.webconf
@property
- def _singlerepo(self) -> Optional[Text]:
+ def _singlerepo(self) -> Optional[str]:
"""Return repository path if serving single repository"""
# TODO: The caller crashes if this returns None with:
# `'ServeDialog' object has no attribute '_singlerepo'`
@@ -178,7 +178,7 @@
return self._agent.isBusy()
@property
- def rooturl(self) -> Text:
+ def rooturl(self) -> str:
"""Returns the root URL of the web server"""
# TODO: scheme, hostname ?
return 'http://localhost:%d' % self.port
diff --git a/tortoisehg/hgqt/settings.py b/tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py
+++ b/tortoisehg/hgqt/settings.py
@@ -115,7 +115,7 @@
class SettingsCombo(QComboBox):
- defaults: List[Text]
+ defaults: List[str]
def __init__(self, parent=None, **opts):
QComboBox.__init__(self, parent, toolTip=opts['tooltip'])
diff --git a/tortoisehg/hgqt/shortcutregistry.py b/tortoisehg/hgqt/shortcutregistry.py
--- a/tortoisehg/hgqt/shortcutregistry.py
+++ b/tortoisehg/hgqt/shortcutregistry.py
@@ -41,12 +41,12 @@
_KeySequencesD = Union[
QKeySequence.StandardKey,
- Text,
- Tuple[Text, QKeySequence.StandardKey], # std key with custom modifier
+ str,
+ Tuple[str, QKeySequence.StandardKey], # std key with custom modifier
]
_KeySequencesDefs = Union[_KeySequencesD, List[_KeySequencesD], None]
-_ACTIONS_TABLE: Dict[Text, Tuple[Text, _KeySequencesDefs]] = {
+_ACTIONS_TABLE: Dict[str, Tuple[str, _KeySequencesDefs]] = {
# MQ operations:
# TODO: merge or give better name to deletePatches_, pushMovePatch_,
# and renamePatch_
@@ -193,15 +193,15 @@
return [QKeySequence('%s+%s' % (mod, kstr), QKeySequence.SequenceFormat.PortableText)]
return QKeySequence.keyBindings(data)
-def _parseUserKeySequences(data: List[Text]) -> List[QKeySequence]:
+def _parseUserKeySequences(data: List[str]) -> List[QKeySequence]:
return [QKeySequence(s, QKeySequence.SequenceFormat.PortableText) for s in data]
-def _formatKeySequences(seqs: List[QKeySequence]) -> List[Text]:
+def _formatKeySequences(seqs: List[QKeySequence]) -> List[str]:
return [b.toString(QKeySequence.SequenceFormat.PortableText) for b in seqs]
-def _formatToolTip(label: Text,
- toolTip: Text,
- seqs: List[QKeySequence]) -> Text:
+def _formatToolTip(label: str,
+ toolTip: str,
+ seqs: List[QKeySequence]) -> str:
"""Build tool tip from current label/toolTip and shortcuts
>>> stext = '%s(%s)%s' % (_TOOLTIP_SHORTCUT_START_TAG, 'A',
@@ -245,7 +245,7 @@
and QAction instances.
"""
- _userKeys: Dict[Text, List[QKeySequence]]
+ _userKeys: Dict[str, List[QKeySequence]]
def __init__(self):
self._defaultKeys = {name: _parseDefaultKeySequences(seq)
@@ -285,28 +285,28 @@
qs.remove(name)
qs.endGroup()
- def allNames(self) -> List[Text]:
+ def allNames(self) -> List[str]:
"""List of all known action names"""
return sorted(_ACTIONS_TABLE)
- def actionLabel(self, name: Text) -> Text:
+ def actionLabel(self, name: str) -> str:
label, _default = _ACTIONS_TABLE[name]
return label
- def defaultKeySequences(self, name: Text) -> List[QKeySequence]:
+ def defaultKeySequences(self, name: str) -> List[QKeySequence]:
return self._defaultKeys[name]
- def keySequences(self, name: Text) -> List[QKeySequence]:
+ def keySequences(self, name: str) -> List[QKeySequence]:
if name in self._userKeys:
return self._userKeys[name]
return self.defaultKeySequences(name)
- def hasUserKeySequences(self, name: Text) -> bool:
+ def hasUserKeySequences(self, name: str) -> bool:
assert name in _ACTIONS_TABLE, name
return name in self._userKeys
def setUserKeySequences(self,
- name: Text,
+ name: str,
seqs: List[QKeySequence]) -> None:
"""Stores new shortcuts of the specified action
@@ -318,7 +318,7 @@
assert name in _ACTIONS_TABLE, name
self._userKeys[name] = seqs
- def unsetUserKeySequences(self, name: Text) -> None:
+ def unsetUserKeySequences(self, name: str) -> None:
"""Restores the shortcuts of the specified action to default
You'll also want to call saveSettings() and applyChangesToActions().
@@ -330,7 +330,7 @@
class ActionRegistry(ShortcutRegistry):
"""Manages user-configurable shortcuts and QAction instances"""
- _actionsMap: Dict[Text, weakref.WeakSet[QAction]]
+ _actionsMap: Dict[str, weakref.WeakSet[QAction]]
def __init__(self):
super().__init__()
@@ -345,13 +345,13 @@
for name, actions in self._actionsMap.items():
self._updateActions(name, actions)
- def registerAction(self, name: Text, action: QAction) -> None:
+ def registerAction(self, name: str, action: QAction) -> None:
"""Register QAction instance to be updated on applyChangesToActions()"""
assert name in _ACTIONS_TABLE, name
self._actionsMap[name].add(action)
self._updateActions(name, [action])
- def _updateActions(self, name: Text, actions: Iterable[QAction]) -> None:
+ def _updateActions(self, name: str, actions: Iterable[QAction]) -> None:
label = self.actionLabel(name)
seqs = self.keySequences(name)
for a in actions:
diff --git a/tortoisehg/hgqt/shortcutsettings.py b/tortoisehg/hgqt/shortcutsettings.py
--- a/tortoisehg/hgqt/shortcutsettings.py
+++ b/tortoisehg/hgqt/shortcutsettings.py
@@ -128,7 +128,7 @@
def registry(self) -> shortcutregistry.ShortcutRegistry:
return self._registry
- def _currentName(self) -> Text:
+ def _currentName(self) -> str:
it = self._view.currentItem()
if not it:
return ''
diff --git a/tortoisehg/hgqt/tag.py b/tortoisehg/hgqt/tag.py
--- a/tortoisehg/hgqt/tag.py
+++ b/tortoisehg/hgqt/tag.py
@@ -60,9 +60,9 @@
def __init__(self,
repoagent: RepoAgent,
tag: bytes = b'',
- rev: Text = 'tip',
+ rev: str = 'tip',
parent: Optional[QWidget] = None,
- opts: Optional[Dict[Text, Union[bool, bytes]]] = None) -> None:
+ opts: Optional[Dict[str, Union[bool, bytes]]] = None) -> None:
super().__init__(parent)
if opts is None:
opts = {}
@@ -251,8 +251,8 @@
self.customTextLineEdit.setVisible(visible)
def set_status(self,
- text: Text,
- icon: Optional[Union[bool, Text, QIcon]]) -> None:
+ text: str,
+ icon: Optional[Union[bool, str, QIcon]]) -> None:
self.status.setVisible(True)
self.sep.setVisible(True)
self.status.set_status(text, icon)
@@ -261,7 +261,7 @@
self.status.setHidden(True)
self.sep.setHidden(True)
- def _runTag(self, tagname: Text, **opts) -> None:
+ def _runTag(self, tagname: str, **opts) -> None:
if not self._cmdsession.isFinished():
self.set_status(_('Repository command still running'), False)
return
diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
--- a/tortoisehg/hgqt/thgrepo.py
+++ b/tortoisehg/hgqt/thgrepo.py
@@ -452,33 +452,33 @@
return hglib.tounicode(self._repo.root)
def configBool(self,
- section: Text,
- name: Text,
+ section: str,
+ name: str,
default: bool = hgconfig.UNSET_DEFAULT) -> bool:
return self._config.configBool(section, name, default)
def configInt(self,
- section: Text,
- name: Text,
+ section: str,
+ name: str,
default: int = hgconfig.UNSET_DEFAULT) -> int:
return self._config.configInt(section, name, default)
def configString(self,
- section: Text,
- name: Text,
- default: Text = hgconfig.UNSET_DEFAULT) -> Text:
+ section: str,
+ name: str,
+ default: str = hgconfig.UNSET_DEFAULT) -> str:
return self._config.configString(section, name, default)
def configStringList(self,
- section: Text,
- name: Text,
- default: List[Text] = hgconfig.UNSET_DEFAULT) -> List[Text]:
+ section: str,
+ name: str,
+ default: List[str] = hgconfig.UNSET_DEFAULT) -> List[str]:
return self._config.configStringList(section, name, default)
- def configStringItems(self, section: Text) -> List[Tuple[Text, Text]]:
+ def configStringItems(self, section: str) -> List[Tuple[str, str]]:
return self._config.configStringItems(section)
- def hasConfig(self, section: Text, name: Text) -> bool:
+ def hasConfig(self, section: str, name: str) -> bool:
return self._config.hasConfig(section, name)
def displayName(self):
@@ -613,7 +613,7 @@
self.busyChanged.emit(busy)
def runCommand(self,
- cmdline: List[Text],
+ cmdline: List[str],
uihandler: Optional[Union[QWidget, cmdcore.UiHandler]] = None,
overlay: bool = True) -> cmdcore.CmdSession:
"""Executes a single command asynchronously in this repository"""
@@ -621,14 +621,14 @@
return self._cmdagent.runCommand(cmdline, uihandler)
def runCommandSequence(self,
- cmdlines: List[List[Text]],
+ cmdlines: List[List[str]],
uihandler: Optional[Union[QWidget, cmdcore.UiHandler]] = None,
overlay: bool = True) -> cmdcore.CmdSession:
"""Executes a series of commands asynchronously in this repository"""
cmdlines = [self._extendCmdline(l, overlay) for l in cmdlines]
return self._cmdagent.runCommandSequence(cmdlines, uihandler)
- def _extendCmdline(self, cmdline: List[Text], overlay: bool) -> List[Text]:
+ def _extendCmdline(self, cmdline: List[str], overlay: bool) -> List[str]:
if self.hiddenRevsIncluded():
cmdline = ['--hidden'] + cmdline
if overlay and self._overlayurl:
diff --git a/tortoisehg/hgqt/thgstrip.py b/tortoisehg/hgqt/thgstrip.py
--- a/tortoisehg/hgqt/thgstrip.py
+++ b/tortoisehg/hgqt/thgstrip.py
@@ -54,9 +54,9 @@
def __init__(self,
repoagent: RepoAgent,
- rev: Optional[Text] = None,
+ rev: Optional[str] = None,
parent: Optional[QWidget] = None,
- opts: Optional[Dict[Text, Any]] = None) -> None:
+ opts: Optional[Dict[str, Any]] = None) -> None:
super().__init__(parent)
if opts is None:
opts = {}
@@ -208,9 +208,9 @@
def createStripDialog(repoagent: RepoAgent,
- rev: Optional[Text] = None,
+ rev: Optional[str] = None,
parent: Optional[QWidget] = None,
- opts: Optional[Dict[Text, Any]] = None) -> cmdui.CmdControlDialog:
+ opts: Optional[Dict[str, Any]] = None) -> cmdui.CmdControlDialog:
if opts is None:
opts = {}
dlg = cmdui.CmdControlDialog(parent)
diff --git a/tortoisehg/hgqt/update.py b/tortoisehg/hgqt/update.py
--- a/tortoisehg/hgqt/update.py
+++ b/tortoisehg/hgqt/update.py
@@ -50,14 +50,14 @@
from .qtgui import QWidget
from .thgrepo import RepoAgent
- UpdateOpts = Dict[Text, Any]
+ UpdateOpts = Dict[str, Any]
class UpdateWidget(cmdui.AbstractCmdWidget):
def __init__(self,
repoagent: RepoAgent,
- rev: Optional[Union[Text, pycompat.unicode]] = None,
+ rev: Optional[Union[str, pycompat.unicode]] = None,
parent: Optional[QWidget] = None,
opts: Optional[UpdateOpts] = None) -> None:
# TODO: unify the `rev` type
@@ -245,7 +245,7 @@
cmdline += ['--verbose']
cmdline += ['--config', 'ui.merge=internal:' +
(self.autoresolve_chk.isChecked() and 'merge' or 'fail')]
- rev: Text = self.rev_combo.currentText()
+ rev: str = self.rev_combo.currentText()
activatebookmarkmode = self._repoagent.configString(
'tortoisehg', 'activatebookmarks')
@@ -355,7 +355,7 @@
pa = p1.ancestor(p2)
return not clean \
and (p1.rev() == pa.rev() or p2.rev() == pa.rev())
- def confirmupdate() -> Optional[Text]:
+ def confirmupdate() -> Optional[str]:
msg = _('Detected uncommitted local changes in working tree.\n'
'Please select to continue:\n')
data = {'discard': (_('&Discard'),
@@ -426,7 +426,7 @@
def __init__(self,
repoagent: RepoAgent,
- rev: Optional[Union[Text, pycompat.unicode]] = None,
+ rev: Optional[Union[str, pycompat.unicode]] = None,
parent: Optional[QWidget] = None,
opts: Optional[UpdateOpts] = None) -> None:
super().__init__(parent)
diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
--- a/tortoisehg/hgqt/visdiff.py
+++ b/tortoisehg/hgqt/visdiff.py
@@ -187,7 +187,7 @@
def launchtool(cmd: bytes,
opts: Sequence[bytes],
- replace: Dict[Text, Union[bytes, Text]],
+ replace: Dict[str, Union[bytes, str]],
block: bool) -> None:
# TODO: fix up the bytes vs str in the replacement mapping
def quote(match):
@@ -210,7 +210,7 @@
_('Tool launch failure'),
_('%s : %s') % (hglib.tounicode(cmd), hglib.exception_str(e)))
-def filemerge(ui: uimod.ui, fname: Text, patchedfname: Text) -> None:
+def filemerge(ui: uimod.ui, fname: str, patchedfname: str) -> None:
'Launch the preferred visual diff tool for two text files'
detectedtools = hglib.difftools(ui)
if not detectedtools:
@@ -258,7 +258,7 @@
def visualdiff(ui: uimod.ui,
repo: localrepo.localrepository,
pats: Sequence[bytes],
- opts: Dict[Text, Any]) -> Optional[FileSelectionDialog]:
+ opts: Dict[str, Any]) -> Optional[FileSelectionDialog]:
revs = opts.get('rev', [])
change = opts.get('change')
@@ -451,7 +451,7 @@
repoagent = repo._pyqtobj # TODO
# TODO: sort out bytes vs str
- replace: Dict[Text, Union[bytes, Text]] = {
+ replace: Dict[str, Union[bytes, str]] = {
"parent": dir1a,
"parent1": dir1a,
"parent2": dir1b,
@@ -595,7 +595,7 @@
def get_status(file: bytes,
mod: Set[bytes],
add: Set[bytes],
- rem: Set[bytes]) -> Text:
+ rem: Set[bytes]) -> str:
if file in mod:
return 'M'
if file in add:
@@ -611,7 +611,7 @@
self.list.addItem(row)
@pyqtSlot(str)
- def onToolSelected(self, tool: Text) -> None:
+ def onToolSelected(self, tool: str) -> None:
'user selected a tool from the tool combo'
tool = hglib.fromunicode(tool) # pytype: disable=annotation-type-mismatch
assert tool in self.tools, tool
@@ -666,7 +666,7 @@
d2 = self.repo.ui.configbool(b'merge-tools', tool + b'.dirdiff')
self.dbutton.setEnabled(bool(d2))
- def launch(self, fname: Text) -> None:
+ def launch(self, fname: str) -> None:
fname = hglib.fromunicode(fname) # pytype: disable=annotation-type-mismatch
source = self.copies.get(fname, None)
dir1a, dir1b, dir2 = self.dirs
@@ -708,7 +708,7 @@
label2 += b'[merged]'
# Function to quote file/dir names in the argument string
- replace: Dict[Text, Union[bytes, Text]] = {
+ replace: Dict[str, Union[bytes, str]] = {
"parent": file1a,
"parent1": file1a,
"plabel1": label1a,
@@ -729,7 +729,7 @@
rev1a, rev1b, rev2 = self.revs
ctx1a, ctx1b, ctx2 = self.ctxs
- replace: Dict[Text, Union[bytes, Text]] = {
+ replace: Dict[str, Union[bytes, str]] = {
"parent": dir1a,
"parent1": dir1a,
"plabel1": rev1a,
@@ -749,7 +749,7 @@
rev1a, rev1b, rev2 = self.revs
ctx1a, ctx1b, ctx2 = self.ctxs
- replace: Dict[Text, Union[bytes, Text]] = {
+ replace: Dict[str, Union[bytes, str]] = {
"parent": dir1b,
"parent1": dir1b,
"plabel1": rev1b,
@@ -769,7 +769,7 @@
rev1a, rev1b, rev2 = self.revs
ctx1a, ctx1b, ctx2 = self.ctxs
- replace: Dict[Text, Union[bytes, Text]] = {
+ replace: Dict[str, Union[bytes, str]] = {
"parent": dir1a,
"parent1": dir1a,
"plabel1": rev1a,
diff --git a/tortoisehg/hgqt/webconf.py b/tortoisehg/hgqt/webconf.py
--- a/tortoisehg/hgqt/webconf.py
+++ b/tortoisehg/hgqt/webconf.py
@@ -155,7 +155,7 @@
if path:
self.openwebconf(path)
- def openwebconf(self, path: Text) -> None:
+ def openwebconf(self, path: str) -> None:
"""load the specified webconf file"""
path = hglib.fromunicode(path)
c = wconfig.readfile(path)
@@ -170,15 +170,15 @@
if path:
self.savewebconf(path)
- def savewebconf(self, path: Text) -> None:
+ def savewebconf(self, path: str) -> None:
"""save current webconf to the specified file"""
wconfig.writefile(self.webconf, hglib.fromunicode(path))
self.openwebconf(path) # reopen in case file path changed
@pyqtSlot()
def _addpathmap(self,
- path: Optional[Text] = None,
- localpath: Optional[Text] = None) -> None:
+ path: Optional[str] = None,
+ localpath: Optional[str] = None) -> None:
path, localpath = _PathDialog.getaddpathmap(
self, path=path, localpath=localpath,
invalidpaths=self._webconfmodel.paths)
@@ -214,8 +214,8 @@
class _PathDialog(QDialog):
"""Dialog to add/edit path mapping"""
- def __init__(self, title: Text, acceptlabel: Text, path: Optional[Text] = None, localpath: Optional[Text] = None,
- invalidpaths: Optional[Iterable[Text]] = None, parent: Optional[QWidget] = None) -> None:
+ def __init__(self, title: str, acceptlabel: str, path: Optional[str] = None, localpath: Optional[str] = None,
+ invalidpaths: Optional[Iterable[str]] = None, parent: Optional[QWidget] = None) -> None:
super().__init__(parent)
self.setWindowFlags((self.windowFlags() | Qt.WindowType.WindowMinimizeButtonHint)
& ~Qt.WindowType.WindowContextHelpButtonHint)
@@ -250,7 +250,7 @@
addfield('localpath', _('Local Path:'), self._localpath_browse_button)
self._localpath_browse_button.clicked.connect(self._browse_localpath)
- def _initbuttons(self, acceptlabel: Text) -> None:
+ def _initbuttons(self, acceptlabel: str) -> None:
"""initialize dialog buttons"""
self._buttons = QDialogButtonBox(self)
self._accept_button = self._buttons.addButton(QDialogButtonBox.StandardButton.Ok)
@@ -261,12 +261,12 @@
self.layout().addRow(self._buttons)
@property
- def path(self) -> Text:
+ def path(self) -> str:
"""value of path field"""
return self._path_edit.text()
@property
- def localpath(self) -> Text:
+ def localpath(self) -> str:
"""value of localpath field"""
return self._localpath_edit.text()
@@ -296,9 +296,9 @@
@classmethod
def getaddpathmap(cls,
parent: Optional[QWidget],
- path: Optional[Text] = None,
- localpath: Optional[Text] = None,
- invalidpaths: Optional[Iterable[Text]] = None) -> Tuple[Optional[Text], Optional[Text]]:
+ path: Optional[str] = None,
+ localpath: Optional[str] = None,
+ invalidpaths: Optional[Iterable[str]] = None) -> Tuple[Optional[str], Optional[str]]:
d = cls(title=_('Add Path to Serve'), acceptlabel=_('Add'),
path=path, localpath=localpath,
invalidpaths=invalidpaths, parent=parent)
@@ -310,9 +310,9 @@
@classmethod
def geteditpathmap(cls,
parent: Optional[QWidget],
- path: Optional[Text] = None,
- localpath: Optional[Text] = None,
- invalidpaths: Optional[Iterable[Text]] = None) -> Tuple[Optional[Text], Optional[Text]]:
+ path: Optional[str] = None,
+ localpath: Optional[str] = None,
+ invalidpaths: Optional[Iterable[str]] = None) -> Tuple[Optional[str], Optional[str]]:
d = cls(title=_('Edit Path to Serve'), acceptlabel=_('Edit'),
path=path, localpath=localpath,
invalidpaths=invalidpaths, parent=parent)
@@ -356,17 +356,17 @@
return self._COLUMNS[section][0]
@property
- def paths(self) -> List[Text]:
+ def paths(self) -> List[str]:
"""return list of known paths"""
return [hglib.tounicode(e) for e in self._config[b'paths']]
- def getpathmapat(self, row: int) -> Tuple[Text, ...]:
+ def getpathmapat(self, row: int) -> Tuple[str, ...]:
"""return pair of (path, localpath) at the specified index"""
assert 0 <= row and row < self.rowCount(), row
return tuple(hglib.tounicode(e)
for e in self._config.items(b'paths')[row])
- def addpathmap(self, path: Text, localpath: Text) -> None:
+ def addpathmap(self, path: str, localpath: str) -> None:
"""add path mapping to serve"""
assert path not in self.paths, path
self.beginInsertRows(QModelIndex(), self.rowCount(), self.rowCount())
@@ -376,7 +376,7 @@
finally:
self.endInsertRows()
- def setpathmap(self, path: Text, localpath: Text) -> None:
+ def setpathmap(self, path: str, localpath: str) -> None:
"""change path mapping at the specified index"""
self._config.set(b'paths', hglib.fromunicode(path),
hglib.fromunicode(localpath))
@@ -384,7 +384,7 @@
self.dataChanged.emit(self.index(row, 0),
self.index(row, self.columnCount()))
- def removepathmap(self, path: Text) -> None:
+ def removepathmap(self, path: str) -> None:
"""remove path from mapping"""
row = self._indexofpath(path)
self.beginRemoveRows(QModelIndex(), row, row)
@@ -393,7 +393,7 @@
finally:
self.endRemoveRows()
- def _indexofpath(self, path: Text) -> int:
+ def _indexofpath(self, path: str) -> int:
path = hglib.fromunicode(path)
assert path in self._config[b'paths'], path
return list(self._config[b'paths']).index(path)
diff --git a/tortoisehg/util/cachethg.py b/tortoisehg/util/cachethg.py
--- a/tortoisehg/util/cachethg.py
+++ b/tortoisehg/util/cachethg.py
@@ -27,8 +27,8 @@
debugging = False
enabled = True
localonly = False
-includepaths: List[Text] = []
-excludepaths: List[Text] = []
+includepaths: List[str] = []
+excludepaths: List[str] = []
try:
from mercurial.windows import winreg
@@ -79,10 +79,10 @@
UNRESOLVED = 'U'
# file status cache
-overlay_cache: Dict[Optional[Text], Optional[Text]] = {}
+overlay_cache: Dict[Optional[str], Optional[str]] = {}
cache_tick_count = 0
-cache_root: Optional[Text] = None
-cache_pdir: Optional[Text] = None
+cache_root: Optional[str] = None
+cache_pdir: Optional[str] = None
def add_dirs(list: List[bytes]) -> None:
@@ -99,8 +99,8 @@
list.extend(dirs)
-def get_state(upath: Text,
- repo: Optional[localrepo.localrepository] = None) -> Text:
+def get_state(upath: str,
+ repo: Optional[localrepo.localrepository] = None) -> str:
"""
Get the state of a given path in source control.
"""
@@ -108,8 +108,8 @@
return states and states[0] or NOT_IN_REPO
-def get_states(path: Text,
- repo: Optional[localrepo.localrepository] = None) -> Text:
+def get_states(path: str,
+ repo: Optional[localrepo.localrepository] = None) -> str:
"""
Get the states of a given path in source control.
"""
@@ -262,5 +262,5 @@
return status
-def add(path: Text, state: Text) -> None:
+def add(path: str, state: str) -> None:
overlay_cache[path] = overlay_cache.get(path, '') + state
diff --git a/tortoisehg/util/gpg.py b/tortoisehg/util/gpg.py
--- a/tortoisehg/util/gpg.py
+++ b/tortoisehg/util/gpg.py
@@ -23,7 +23,7 @@
if
os.name == 'nt':
from mercurial.windows import winreg
- def findgpg(ui: uimod.ui) -> List[Text]:
+ def findgpg(ui: uimod.ui) -> List[str]:
path = []
for key in (r"Software\GNU\GnuPG", r"Software\Wow6432Node\GNU\GnuPG"):
try:
@@ -42,5 +42,5 @@
return path
else:
- def findgpg(ui: uimod.ui) -> List[Text]:
+ def findgpg(ui: uimod.ui) -> List[str]:
return []
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -155,10 +155,10 @@
if TYPE_CHECKING:
@overload
- def fromunicode(s: Text, errors: Text = 'strict') -> bytes:
+ def fromunicode(s: str, errors: str = 'strict') -> bytes:
pass
@overload
- def fromunicode(s: None, errors: Text = 'strict') -> None:
+ def fromunicode(s: None, errors: str = 'strict') -> None:
pass
def fromunicode(s, errors='strict'):
@@ -288,7 +288,7 @@
if repo.branchtip(branch) == ctx.node():
return branch
-def getrevisionlabel(repo, rev: Optional[int]) -> Optional[Text]:
+def getrevisionlabel(repo, rev: Optional[int]) -> Optional[str]:
"""Return symbolic name for the specified revision or stringfy it"""
if rev is None:
return None # no symbol for working revision
@@ -317,7 +317,7 @@
cur = cur[8:]
return cur
-def gitcommit_full(ctx) -> Optional[Text]:
+def gitcommit_full(ctx) -> Optional[str]:
"""
If the hggit extension is loaded, and the repository is a git clone,
returns the complete git commit hash of the current revision
@@ -334,7 +334,7 @@
return fullgitnode
-def gitcommit_short(ctx) -> Optional[Text]:
+def gitcommit_short(ctx) -> Optional[str]:
"""
If the hggit extension is loaded, and the repository is a git clone,
returns the short (12 digits) git commit hash of the current revision
@@ -343,7 +343,7 @@
fullgitnode = gitcommit_full(ctx)
return None if fullgitnode is None else fullgitnode[:12]
-def getqqueues(repo) -> List[Text]:
+def getqqueues(repo) -> List[str]:
ui = repo.ui.copy()
ui.quiet = True # don't append "(active)"
ui.pushbuffer()
@@ -386,7 +386,7 @@
return operation_in_progress(repo, b"rebasestate")
-def readundodesc(repo) -> Tuple[Text, int]:
+def readundodesc(repo) -> Tuple[str, int]:
"""Read short description and changelog size of last transaction"""
if os.path.exists(repo.sjoin(b'undo')):
try:
@@ -411,17 +411,17 @@
text = b''.join(sum((list(hlines) for _hrange, hlines in hunks), []))
return b'\n'.join(headers) + b'\n' + text
-def enabledextensions() -> Dict[Text, bytes]:
+def enabledextensions() -> Dict[str, bytes]:
"""Return the {name: shortdesc} dict of enabled extensions
shortdesc is in local encoding.
"""
return {pycompat.sysstr(k): v for k, v in extensions.enabled().items()}
-def disabledextensions() -> Dict[Text, bytes]:
+def disabledextensions() -> Dict[str, bytes]:
return {pycompat.sysstr(k): v for k, v in extensions.disabled().items()}
-def allextensions() -> Dict[Text, bytes]:
+def allextensions() -> Dict[str, bytes]:
"""Return the {name: shortdesc} dict of known extensions
shortdesc is in local encoding.
@@ -444,7 +444,7 @@
return exts
-def validateextensions(enabledexts: AbstractSet[Text]) -> Dict[Text, bytes]:
+def validateextensions(enabledexts: AbstractSet[str]) -> Dict[str, bytes]:
"""Report extensions which should be disabled
Returns the dict {name: message} of extensions expected to be disabled.
@@ -520,13 +520,13 @@
return canonpats
-def normpath(path: Text) -> Text:
+def normpath(path: str) -> str:
"""Normalize a path in the same manner as mercurial.util.normpath()."""
# TODO: Do a unicode port of util.normpath() here.
return tounicode(util.normpath(fromunicode(path)))
-def normreporoot(path: Text) -> Text:
+def normreporoot(path: str) -> str:
"""Normalize repo root path in the same manner as localrepository"""
# see localrepo.localrepository and scmutil.vfs
lpath = fromunicode(path)
@@ -619,7 +619,7 @@
)
def tortoisehgtools(uiorconfig: Union[IniConfig, uimod.ui],
- selectedlocation: Optional[Text] = None) -> Tuple[Dict[Text, Dict[Text, Union[Text, bool]]], List[Text]]:
+ selectedlocation: Optional[str] = None) -> Tuple[Dict[str, Dict[str, Union[str, bool]]], List[str]]:
"""Parse 'tortoisehg-tools' section of ini file.
>>> from pprint import pprint
@@ -735,7 +735,7 @@
def configlist(section, name):
return uiorconfig.get(section, name, b'').split()
- tools: Dict[Text, Dict[Text, Union[Text, bool]]] = {}
+ tools: Dict[str, Dict[str, Union[str, bool]]] = {}
for key, value in configitems(b'tortoisehg-tools'):
toolname, field = tounicode(key).split('.', 1)
if toolname not in tools:
@@ -759,8 +759,8 @@
guidef = configlist(b'tortoisehg',
pycompat.sysbytes(selectedlocation)) or []
- toollist: List[Text] = []
- selectedtools: Dict[Text, Dict[Text, Union[Text, bool]]] = {}
+ toollist: List[str] = []
+ selectedtools: Dict[str, Dict[str, Union[str, bool]]] = {}
for name in guidef:
name = tounicode(name)
if name != '|':
@@ -808,7 +808,7 @@
return
return name
-def extractchoices(prompttext: Text) -> Tuple[Text, List[Tuple[Text, Text]]]:
+def extractchoices(prompttext: str) -> Tuple[str, List[Tuple[str, str]]]:
"""Extract prompt message and list of choice (char, label) pairs
This is slightly different from ui.extractchoices() in that
@@ -966,8 +966,8 @@
summary = l and l[0] or ''
return u'%s@%s%s:%s "%s"' % (author, rev, source, date, summary)
-def longsummary(description: Union[bytes, Text],
- limit: Optional[int] = None) -> Text:
+def longsummary(description: Union[bytes, str],
+ limit: Optional[int] = None) -> str:
summary = tounicode(description)
lines = summary.splitlines()
if not lines:
@@ -1031,7 +1031,7 @@
return os.path.join(wsub, wsubsub), wfileinsub, sctx
return None, wfile, ctx
-def getLineSeparator(line: Text) -> Text:
+def getLineSeparator(line: str) -> str:
"""Get the line separator used on a given line"""
# By default assume the default OS line separator
linesep = os.linesep
@@ -1080,7 +1080,7 @@
def _escapecharrepl(m):
return _escapecharmap[ord(m.group(0))]
-def escapeascii(s: Text) -> Text:
+def escapeascii(s: str) -> str:
r"""Escape string to be embedded as a literal; like Python string_escape,
but keeps 8bit characters and can process unicode
@@ -1092,7 +1092,7 @@
s = _stringify(s)
return _escapecharre.sub(_escapecharrepl, s)
-def escapepath(path: Text) -> Text:
+def escapepath(path: str) -> str:
r"""Convert path to command-line-safe string; path must be relative to
the repository root
@@ -1108,7 +1108,7 @@
else:
return p
-def escaperev(rev: int, default: Optional[Text] = None) -> Text:
+def escaperev(rev: int, default: Optional[str] = None) -> str:
"""Convert revision number to command-line-safe string"""
if rev is None:
return default
@@ -1123,7 +1123,7 @@
else:
return '%s:%s' % (escaperev(a), escaperev(b))
-def compactrevs(revs: List[int]) -> Text:
+def compactrevs(revs: List[int]) -> str:
"""Build command-line-safe revspec from list of revision numbers; revs
should be sorted in ascending order to get compact form
@@ -1208,7 +1208,7 @@
return ''.join(ret)
-def formatfilespec(expr: Text, *args) -> Text:
+def formatfilespec(expr: str, *args) -> str:
"""Build fileset expression by template and positional arguments
Supported arguments:
@@ -1224,7 +1224,7 @@
listfuncs = {}
return _formatspec(expr, args, filesetlang.parse, listfuncs)
-def formatrevspec(expr: Text, *args) -> Text:
+def formatrevspec(expr: str, *args) -> str:
r"""Build revset expression by template and positional arguments
Supported arguments:
@@ -1250,7 +1250,7 @@
listfuncs = {'d': '_intlist', 's': '_list'}
return _formatspec(expr, args, revsetlang.parse, listfuncs)
-def buildcmdargs(name: Text, *args, **opts) -> List[Text]:
+def buildcmdargs(name: str, *args, **opts) -> List[str]:
r"""Build list of command-line arguments
>>> buildcmdargs('push', branch='foo')
@@ -1342,7 +1342,7 @@
else:
return arg
-def prettifycmdline(cmdline: List[Text]) -> Text:
+def prettifycmdline(cmdline: List[str]) -> str:
r"""Build pretty command-line string for display
>>> prettifycmdline(['log', 'foo\\bar', '', 'foo bar', 'foo"bar'])
@@ -1359,7 +1359,7 @@
"""
return ' '.join(_reprcmdarg(e) for e in cmdline)
-def parsecmdline(cmdline: Text, cwd: Text) -> List[Text]:
+def parsecmdline(cmdline: str, cwd: str) -> List[str]:
r"""Split command line string to imitate a unix shell
>>> origfuncs = glob.glob, os.path.expanduser, os.path.expandvars
diff --git a/tortoisehg/util/menuthg.py b/tortoisehg/util/menuthg.py
--- a/tortoisehg/util/menuthg.py
+++ b/tortoisehg/util/menuthg.py
@@ -30,7 +30,7 @@
MenuT = List[Union["TortoiseMenu", "TortoiseMenuSep"]]
-def _(msgid: Text) -> Dict[Text, Text]:
+def _(msgid: str) -> Dict[str, str]:
return {'id': msgid, 'str': gettext(msgid)}
thgcmenu = {
@@ -115,10 +115,10 @@
class TortoiseMenu:
def __init__(self,
- menutext: Text,
- helptext: Text,
- hgcmd: Optional[Text],
- icon: Optional[Text] = None,
+ menutext: str,
+ helptext: str,
+ hgcmd: Optional[str],
+ icon: Optional[str] = None,
state: bool = True) -> None:
self.menutext = menutext
self.helptext = helptext
@@ -136,20 +136,20 @@
class TortoiseSubmenu(TortoiseMenu):
def __init__(self,
- menutext: Text,
- helptext: Text,
+ menutext: str,
+ helptext: str,
menus: Optional[MenuT] = None,
- icon: Optional[Text] = None) -> None:
+ icon: Optional[str] = None) -> None:
TortoiseMenu.__init__(self, menutext, helptext, None, icon)
if menus is None:
menus: MenuT = []
self.menus = menus[:]
def add_menu(self,
- menutext: Text,
- helptext: Text,
- hgcmd: Optional[Text],
- icon: Optional[Text] = None,
+ menutext: str,
+ helptext: str,
+ hgcmd: Optional[str],
+ icon: Optional[str] = None,
state: bool = True) -> None:
self.menus.append(TortoiseMenu(menutext, helptext,
hgcmd, icon, state))
@@ -184,8 +184,8 @@
def __init__(self,
ui: uimod.ui,
- promoted: List[Text],
- name: Text = "TortoiseHg") -> None:
+ promoted: List[str],
+ name: str = "TortoiseHg") -> None:
self.menus = [[]]
self.ui = ui
self.name = name
@@ -193,8 +193,8 @@
self.promoted = promoted
def add_menu(self,
- hgcmd: Text,
- icon: Optional[Text] = None,
+ hgcmd: str,
+ icon: Optional[str] = None,
state: bool = True) -> None:
if hgcmd in self.promoted:
pos = 0
@@ -226,7 +226,7 @@
return iter(self.get())
-def open_repo(path: Text) -> Optional[localrepo.localrepository]:
+def open_repo(path: str) -> Optional[localrepo.localrepository]:
root = paths.find_root(path)
if root:
try:
@@ -263,8 +263,8 @@
def get_commands_dragdrop(self,
- srcfiles: List[Text],
- destfolder: Text) -> Union[List[Text], thg_menu]:
+ srcfiles: List[str],
+ destfolder: str) -> Union[List[str], thg_menu]:
"""
Get a list of commands valid for the current selection.
@@ -295,7 +295,7 @@
menu.add_menu('dndsynch')
return menu
- def get_norepo_commands(self, cwd: Text, files: List[Text]) -> thg_menu:
+ def get_norepo_commands(self, cwd: str, files: List[str]) -> thg_menu:
menu = thg_menu(hglib.loadui(), self.promoted,
self.name)
menu.add_menu('clone')
menu.add_menu('init')
@@ -307,8 +307,8 @@
def get_commands(self,
repo: localrepo.localrepository,
- cwd: Text,
- files: List[Text]) -> thg_menu:
+ cwd: str,
+ files: List[str]) -> thg_menu:
"""
Get a list of commands valid for the current selection.
diff --git a/tortoisehg/util/paths.py b/tortoisehg/util/paths.py
--- a/tortoisehg/util/paths.py
+++ b/tortoisehg/util/paths.py
@@ -40,7 +40,7 @@
)
@overload
- def _find_root(p: Text, dn: Text) -> Optional[Text]:
+ def _find_root(p: str, dn: str) -> Optional[str]:
pass
@overload
def _find_root(p: bytes, dn: bytes) -> Optional[bytes]:
@@ -57,13 +57,13 @@
return None
return p
-def find_root(path: Optional[Text] = None) -> Optional[Text]:
+def find_root(path: Optional[str] = None) -> Optional[str]:
return _find_root(path or os.getcwd(), '.hg')
def find_root_bytes(path: Optional[bytes] = None) -> Optional[bytes]:
return _find_root(path or encoding.getcwd(), b'.hg')
-def get_tortoise_icon(icon: Text) -> Optional[Text]:
+def get_tortoise_icon(icon: str) -> Optional[str]:
"Find a tortoisehg icon"
icopath = os.path.join(get_icon_path(), icon)
if os.path.isfile(icopath):
@@ -72,22 +72,22 @@
print('icon not found', icon)
return None
-def get_icon_path() -> Text:
+def get_icon_path() -> str:
global icon_path
return icon_path or os.path.join(get_prog_root(), 'icons')
-def get_license_path() -> Text:
+def get_license_path() -> str:
global license_path
return license_path or os.path.join(get_prog_root(), 'COPYING.txt')
-def get_locale_path() -> Text:
+def get_locale_path() -> str:
global locale_path
return locale_path or os.path.join(get_prog_root(), 'locale')
-def _get_hg_path() -> Text:
+def _get_hg_path() -> str:
return os.path.abspath(os.path.join(mercurial.__file__, '..', '..'))
-def get_hg_command() -> List[Text]:
+def get_hg_command() -> List[str]:
"""List of command to execute hg (equivalent to mercurial.util.hgcmd)"""
global _hg_command
if _hg_command is None:
@@ -104,7 +104,7 @@
if
os.name == 'nt':
import win32file # pytype: disable=import-error
- def find_in_path(pgmname: Text) -> Optional[Text]:
+ def find_in_path(pgmname: str) -> Optional[str]:
"return first executable found in search path"
global bin_path
ospath = os.environ['PATH'].split(os.pathsep)
@@ -118,7 +118,7 @@
return ppath + ext
return None
- def _find_hg_command() -> List[Text]:
+ def _find_hg_command() -> List[str]:
if hasattr(sys, 'frozen'):
progdir = get_prog_root()
exe = os.path.join(progdir, 'hg.exe')
@@ -143,12 +143,12 @@
return [python, exe[:-4]]
return [exe]
- def get_prog_root() -> Text:
+ def get_prog_root() -> str:
if getattr(sys, 'frozen', False):
return os.path.dirname(sys.executable)
return os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
- def get_thg_command() -> List[Text]:
+ def get_thg_command() -> List[str]:
if getattr(sys, 'frozen', False):
return [sys.executable]
return [sys.executable] + sys.argv[:1]
@@ -170,7 +170,7 @@
else: # Not Windows
- def find_in_path(pgmname: Text) -> Optional[Text]:
+ def find_in_path(pgmname: str) -> Optional[str]:
""" return first executable found in search path """
global bin_path
ospath = os.environ['PATH'].split(os.pathsep)
@@ -181,7 +181,7 @@
return ppath
return None
- def _find_hg_command() -> List[Text]:
+ def _find_hg_command() -> List[str]:
# look for in-place build, i.e. "make local"
exe = os.path.join(_get_hg_path(), 'hg')
if os.path.exists(exe):
@@ -192,11 +192,11 @@
return ['hg']
return [exe]
- def get_prog_root() -> Text:
+ def get_prog_root() -> str:
path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
return path
- def get_thg_command() -> List[Text]:
+ def get_thg_command() -> List[str]:
return sys.argv[:1]
def is_unc_path(path: bytes) -> bool:
diff --git a/tortoisehg/util/version.py b/tortoisehg/util/version.py
--- a/tortoisehg/util/version.py
+++ b/tortoisehg/util/version.py
@@ -27,7 +27,7 @@
@util.cachefunc
-def liveversion() -> Tuple[Text, Text]:
+def liveversion() -> Tuple[str, str]:
'Attempt to read the version from the live repository'
utilpath = os.path.dirname(os.path.realpath(__file__))
thgpath = os.path.dirname(os.path.dirname(utilpath))
@@ -64,7 +64,7 @@
version = pycompat.sysstr(u.popbuffer()).rpartition(':')[2] + l[0]
return pycompat.sysstr(repo[None].branch()), version
-def version() -> Text:
+def version() -> str:
try:
branch, version = liveversion()
return version
@@ -79,7 +79,7 @@
def version_bytes() -> bytes:
return encoding.strtolocal(version())
-def package_version() -> Text:
+def package_version() -> str:
try:
branch, version = liveversion()
return _build_package_version(branch, version)
@@ -91,7 +91,7 @@
except ImportError:
return 'unknown'
-def _build_package_version(branch: Text, version: Text) -> Text:
+def _build_package_version(branch: str, version: str) -> str:
"""
>>> _build_package_version('default', '4.8+10')
'4.8.5010'