[PATCH 1 of 4] typing: convert (pycompat|hglib).TYPE_CHECKING to typing.TYPE_CHECKING

0 views
Skip to first unread message

Matt Harbison

unread,
Mar 1, 2025, 9:55:58 PMMar 1
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1735184634 18000
# Wed Dec 25 22:43:54 2024 -0500
# Branch stable
# Node ID b3577efbf1072cf247cbe1b69b0f8eab7b6be0c6
# Parent abb3512580cd16a371ac690863b56ef60657b028
# EXP-Topic cleanup
typing: convert (pycompat|hglib).TYPE_CHECKING to typing.TYPE_CHECKING

We've switched to this in core hg, and there have definitely been scenarios
where the `pycompat` variable didn't evaluate as expected.

diff --git a/TortoiseHgOverlayServer.py b/TortoiseHgOverlayServer.py
--- a/TortoiseHgOverlayServer.py
+++ b/TortoiseHgOverlayServer.py
@@ -13,6 +13,7 @@

import os
import sys
+import typing

if hasattr(sys, "frozen"):
if sys.frozen == 'windows_exe':
@@ -116,7 +117,7 @@
from tortoisehg.util.i18n import _
from tortoisehg.util import hglib, thread2, paths, shlib, version

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Iterable,
List,
diff --git a/contrib/nautilus-thg.py b/contrib/nautilus-thg.py
--- a/contrib/nautilus-thg.py
+++ b/contrib/nautilus-thg.py
@@ -24,6 +24,7 @@

import os
import sys
+import typing

thg_main = 'thg'

@@ -59,7 +60,7 @@

from tortoisehg.util import hglib, menuthg, paths, debugthg, cachethg

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Dict,
diff --git a/tortoisehg/hgqt/archive.py b/tortoisehg/hgqt/archive.py
--- a/tortoisehg/hgqt/archive.py
+++ b/tortoisehg/hgqt/archive.py
@@ -9,6 +9,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
pyqtSlot,
@@ -42,7 +43,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/hgqt/backout.py b/tortoisehg/hgqt/backout.py
--- a/tortoisehg/hgqt/backout.py
+++ b/tortoisehg/hgqt/backout.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QSettings,
QSize,
@@ -42,7 +44,7 @@
wctxcleaner,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
Text,
diff --git a/tortoisehg/hgqt/clone.py b/tortoisehg/hgqt/clone.py
--- a/tortoisehg/hgqt/clone.py
+++ b/tortoisehg/hgqt/clone.py
@@ -10,6 +10,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
QDir,
@@ -45,7 +46,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
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
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtgui import (
QSizePolicy,
QLineEdit,
@@ -23,7 +25,7 @@
cmdui,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/cmdcore.py b/tortoisehg/hgqt/cmdcore.py
--- a/tortoisehg/hgqt/cmdcore.py
+++ b/tortoisehg/hgqt/cmdcore.py
@@ -12,6 +12,7 @@
import struct
import sys
import time
+import typing

from mercurial import (
pycompat,
@@ -38,7 +39,7 @@
)
from ..util.i18n import _

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Callable,
Dict,
@@ -65,7 +66,7 @@
return tuple.__new__(cls, (hglib.tounicode(topic), pos,
hglib.tounicode(item), hglib.tounicode(unit), total))

- if hglib.TYPE_CHECKING:
+ if typing.TYPE_CHECKING:
# pseudo implementation to help pytype (TODO: replace with attr.s)
def __init__(self,
topic: Union[bytes, str],
diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py
+++ b/tortoisehg/hgqt/commit.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
import os
import re
import tempfile
@@ -87,7 +89,7 @@
)
from .messageentry import MessageEntry

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Callable,
Dict,
diff --git a/tortoisehg/hgqt/customtools.py b/tortoisehg/hgqt/customtools.py
--- a/tortoisehg/hgqt/customtools.py
+++ b/tortoisehg/hgqt/customtools.py
@@ -19,6 +19,7 @@
from __future__ import annotations

import re
+import typing

from typing import (
Dict,
@@ -58,7 +59,7 @@
from ..util.i18n import _
from . import qtlib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
)
diff --git a/tortoisehg/hgqt/filectxactions.py b/tortoisehg/hgqt/filectxactions.py
--- a/tortoisehg/hgqt/filectxactions.py
+++ b/tortoisehg/hgqt/filectxactions.py
@@ -11,6 +11,7 @@

import os
import re
+import typing

from typing import (
Any,
@@ -63,7 +64,7 @@
)


-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from mercurial import (
localrepo,
ui as uimod,
diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
--- a/tortoisehg/hgqt/filedata.py
+++ b/tortoisehg/hgqt/filedata.py
@@ -8,6 +8,7 @@
from __future__ import annotations

import os, posixpath
+import typing

from typing import (
List,
@@ -42,7 +43,7 @@
_TSubrepoData = TypeVar('_TSubrepoData', bound='SubrepoData')
_T_AbstractFileData = TypeVar('_T_AbstractFileData', bound='_AbstractFileData')

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from mercurial import (
context,
localrepo,
diff --git a/tortoisehg/hgqt/filedialogs.py b/tortoisehg/hgqt/filedialogs.py
--- a/tortoisehg/hgqt/filedialogs.py
+++ b/tortoisehg/hgqt/filedialogs.py
@@ -20,6 +20,7 @@
from __future__ import annotations

import difflib
+import typing

from .qsci import (
QsciScintilla,
@@ -70,7 +71,7 @@
)
from .qscilib import Scintilla

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/hgqt/fileencoding.py b/tortoisehg/hgqt/fileencoding.py
--- a/tortoisehg/hgqt/fileencoding.py
+++ b/tortoisehg/hgqt/fileencoding.py
@@ -8,6 +8,7 @@
from __future__ import annotations

import codecs
+import typing

from typing import (
Dict,
@@ -29,7 +30,7 @@
from ..util.i18n import _


-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from mercurial import (
ui as uimod,
)
diff --git a/tortoisehg/hgqt/filelistview.py b/tortoisehg/hgqt/filelistview.py
--- a/tortoisehg/hgqt/filelistview.py
+++ b/tortoisehg/hgqt/filelistview.py
@@ -16,6 +16,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QModelIndex,
Qt,
@@ -33,7 +35,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
--- a/tortoisehg/hgqt/fileview.py
+++ b/tortoisehg/hgqt/fileview.py
@@ -10,6 +10,7 @@
import difflib
import os
import re
+import typing

from typing import (
cast,
@@ -72,7 +73,7 @@
visdiff,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
)
diff --git a/tortoisehg/hgqt/graft.py b/tortoisehg/hgqt/graft.py
--- a/tortoisehg/hgqt/graft.py
+++ b/tortoisehg/hgqt/graft.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QSettings,
QTimer,
@@ -35,7 +37,7 @@
wctxcleaner,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/graphopt.py b/tortoisehg/hgqt/graphopt.py
--- a/tortoisehg/hgqt/graphopt.py
+++ b/tortoisehg/hgqt/graphopt.py
@@ -17,6 +17,7 @@

import collections
import itertools
+import typing

from mercurial import (
pycompat,
@@ -25,7 +26,6 @@
)

from ..util import (
- hglib,
obsoleteutil,
)
from . import (
@@ -37,7 +37,7 @@
LINE_TYPE_OBSOLETE,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Tuple,
diff --git a/tortoisehg/hgqt/hgconfig.py b/tortoisehg/hgqt/hgconfig.py
--- a/tortoisehg/hgqt/hgconfig.py
+++ b/tortoisehg/hgqt/hgconfig.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from mercurial import (
pycompat,
ui as uimod,
@@ -16,7 +18,7 @@
hglib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Text,
diff --git a/tortoisehg/hgqt/hgignore.py b/tortoisehg/hgqt/hgignore.py
--- a/tortoisehg/hgqt/hgignore.py
+++ b/tortoisehg/hgqt/hgignore.py
@@ -9,6 +9,8 @@

import os
import re
+import typing
+
from typing import (
cast,
Iterable,
@@ -65,7 +67,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from .thgrepo import RepoAgent

class HgignoreDialog(QDialog):
diff --git a/tortoisehg/hgqt/hginit.py b/tortoisehg/hgqt/hginit.py
--- a/tortoisehg/hgqt/hginit.py
+++ b/tortoisehg/hgqt/hginit.py
@@ -9,6 +9,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
pyqtSignal,
@@ -33,7 +34,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/hgrcutil.py b/tortoisehg/hgqt/hgrcutil.py
--- a/tortoisehg/hgqt/hgrcutil.py
+++ b/tortoisehg/hgqt/hgrcutil.py
@@ -8,15 +8,13 @@
from __future__ import annotations

import os
+import typing

from tortoisehg.hgqt import qtlib
from tortoisehg.util import wconfig
from tortoisehg.util.i18n import _
-from tortoisehg.util import (
- hglib,
-)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/lfprompt.py b/tortoisehg/hgqt/lfprompt.py
--- a/tortoisehg/hgqt/lfprompt.py
+++ b/tortoisehg/hgqt/lfprompt.py
@@ -8,13 +8,14 @@
from __future__ import annotations

import os
+import typing

from mercurial import error, match
from tortoisehg.hgqt import qtlib
from tortoisehg.util import hglib
from tortoisehg.util.i18n import _

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/locktool.py b/tortoisehg/hgqt/locktool.py
--- a/tortoisehg/hgqt/locktool.py
+++ b/tortoisehg/hgqt/locktool.py
@@ -8,6 +8,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
QModelIndex,
@@ -43,7 +44,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/hgqt/manifestmodel.py b/tortoisehg/hgqt/manifestmodel.py
--- a/tortoisehg/hgqt/manifestmodel.py
+++ b/tortoisehg/hgqt/manifestmodel.py
@@ -12,6 +12,7 @@

import os
import re
+import typing

from .qtcore import (
QAbstractItemModel,
@@ -47,7 +48,7 @@
visdiff,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Dict,
diff --git a/tortoisehg/hgqt/mq.py b/tortoisehg/hgqt/mq.py
--- a/tortoisehg/hgqt/mq.py
+++ b/tortoisehg/hgqt/mq.py
@@ -9,6 +9,7 @@

import os
import re
+import typing

from typing import (
List,
@@ -66,7 +67,7 @@
rejects,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
)
diff --git a/tortoisehg/hgqt/phabreview.py b/tortoisehg/hgqt/phabreview.py
--- a/tortoisehg/hgqt/phabreview.py
+++ b/tortoisehg/hgqt/phabreview.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from mercurial import (
pycompat,
)
@@ -40,7 +42,7 @@
from .hgemail import _ChangesetsModel
from .phabreview_ui import Ui_PhabReviewDialog

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Dict,
diff --git a/tortoisehg/hgqt/pick.py b/tortoisehg/hgqt/pick.py
--- a/tortoisehg/hgqt/pick.py
+++ b/tortoisehg/hgqt/pick.py
@@ -8,6 +8,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QSettings,
QTimer,
@@ -35,7 +37,7 @@
wctxcleaner,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/postreview.py b/tortoisehg/hgqt/postreview.py
--- a/tortoisehg/hgqt/postreview.py
+++ b/tortoisehg/hgqt/postreview.py
@@ -19,6 +19,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QSettings,
QThread,
@@ -49,7 +51,7 @@
from .hgemail import _ChangesetsModel
from .postreview_ui import Ui_PostReviewDialog

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/hgqt/prune.py b/tortoisehg/hgqt/prune.py
--- a/tortoisehg/hgqt/prune.py
+++ b/tortoisehg/hgqt/prune.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QTimer,
pyqtSlot,
@@ -32,7 +34,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
Text,
diff --git a/tortoisehg/hgqt/rebase.py b/tortoisehg/hgqt/rebase.py
--- a/tortoisehg/hgqt/rebase.py
+++ b/tortoisehg/hgqt/rebase.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QSettings,
QTimer,
@@ -37,7 +39,7 @@
wctxcleaner,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/rename.py b/tortoisehg/hgqt/rename.py
--- a/tortoisehg/hgqt/rename.py
+++ b/tortoisehg/hgqt/rename.py
@@ -10,6 +10,7 @@

import os
import sys
+import typing

from .qtcore import (
pyqtSlot,
@@ -39,7 +40,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/repofilter.py b/tortoisehg/hgqt/repofilter.py
--- a/tortoisehg/hgqt/repofilter.py
+++ b/tortoisehg/hgqt/repofilter.py
@@ -9,6 +9,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
QEvent,
@@ -46,7 +47,7 @@
revset,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py
+++ b/tortoisehg/hgqt/repomodel.py
@@ -19,6 +19,7 @@
import binascii
import os
import re
+import typing

from .qtcore import (
QAbstractTableModel,
@@ -53,7 +54,7 @@
graphopt,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
FrozenSet,
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -12,6 +12,7 @@
import os
import shlex # used by runCustomCommand
import subprocess # used by runCustomCommand
+import typing

from typing import (
Optional,
@@ -116,7 +117,7 @@
from .repoview import HgRepoView
from .sync import SyncWidget

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Callable,
Dict,
diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -8,6 +8,7 @@
from __future__ import annotations

import os
+import typing

from .qtcore import (
QAbstractTableModel,
@@ -52,7 +53,7 @@
visdiff,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/serve.py b/tortoisehg/hgqt/serve.py
--- a/tortoisehg/hgqt/serve.py
+++ b/tortoisehg/hgqt/serve.py
@@ -9,6 +9,7 @@

import os
import tempfile
+import typing

from .qtcore import (
Qt,
@@ -39,7 +40,7 @@
from .serve_ui import Ui_ServeDialog
from .webconf import WebconfForm

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Text,
diff --git a/tortoisehg/hgqt/settings.py b/tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py
+++ b/tortoisehg/hgqt/settings.py
@@ -8,6 +8,8 @@
from __future__ import annotations

import os
+import typing
+
from typing import (
Optional,
)
@@ -83,7 +85,7 @@
thgrepo,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Text,
diff --git a/tortoisehg/hgqt/shortcutregistry.py b/tortoisehg/hgqt/shortcutregistry.py
--- a/tortoisehg/hgqt/shortcutregistry.py
+++ b/tortoisehg/hgqt/shortcutregistry.py
@@ -8,6 +8,7 @@
from __future__ import annotations

import collections
+import typing
import weakref

from .qtcore import (
@@ -29,7 +30,7 @@

from ..util.i18n import _

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
Iterable,
diff --git a/tortoisehg/hgqt/shortcutsettings.py b/tortoisehg/hgqt/shortcutsettings.py
--- a/tortoisehg/hgqt/shortcutsettings.py
+++ b/tortoisehg/hgqt/shortcutsettings.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
QModelIndex,
QTimer,
@@ -38,7 +40,7 @@

from ..util.i18n import _

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
Text,
diff --git a/tortoisehg/hgqt/sync.py b/tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py
+++ b/tortoisehg/hgqt/sync.py
@@ -11,6 +11,7 @@
import os
import re
import tempfile
+import typing

from .qtcore import (
QAbstractTableModel,
@@ -83,7 +84,7 @@
thgrepo,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
Iterable,
diff --git a/tortoisehg/hgqt/tag.py b/tortoisehg/hgqt/tag.py
--- a/tortoisehg/hgqt/tag.py
+++ b/tortoisehg/hgqt/tag.py
@@ -7,6 +7,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
Qt,
pyqtSlot,
@@ -37,7 +39,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
Optional,
diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
--- a/tortoisehg/hgqt/thgrepo.py
+++ b/tortoisehg/hgqt/thgrepo.py
@@ -16,6 +16,7 @@
import tempfile
import re
import time
+import typing

from .qtcore import (
QFile,
@@ -51,7 +52,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/hgqt/thgstrip.py b/tortoisehg/hgqt/thgstrip.py
--- a/tortoisehg/hgqt/thgstrip.py
+++ b/tortoisehg/hgqt/thgstrip.py
@@ -8,6 +8,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
Qt,
pyqtSlot,
@@ -34,7 +36,7 @@
qtlib,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Dict,
diff --git a/tortoisehg/hgqt/update.py b/tortoisehg/hgqt/update.py
--- a/tortoisehg/hgqt/update.py
+++ b/tortoisehg/hgqt/update.py
@@ -9,6 +9,8 @@

from __future__ import annotations

+import typing
+
from .qtcore import (
pyqtSlot,
)
@@ -37,7 +39,7 @@
resolve,
)

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Dict,
diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
--- a/tortoisehg/hgqt/visdiff.py
+++ b/tortoisehg/hgqt/visdiff.py
@@ -12,6 +12,7 @@
import stat
import subprocess
import threading
+import typing

from typing import (
Dict,
@@ -54,7 +55,7 @@
from ..util.i18n import _
from . import qtlib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Iterable,
diff --git a/tortoisehg/hgqt/webconf.py b/tortoisehg/hgqt/webconf.py
--- a/tortoisehg/hgqt/webconf.py
+++ b/tortoisehg/hgqt/webconf.py
@@ -7,7 +7,7 @@

from __future__ import annotations

-import os
+import os, typing

from typing import (
Optional,
@@ -40,7 +40,7 @@
from . import qtlib
from .webconf_ui import Ui_WebconfForm

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Any,
Iterable,
diff --git a/tortoisehg/util/cachethg.py b/tortoisehg/util/cachethg.py
--- a/tortoisehg/util/cachethg.py
+++ b/tortoisehg/util/cachethg.py
@@ -7,12 +7,12 @@

from __future__ import annotations

-import os
+import os, typing

from mercurial import hg, error, pycompat, scmutil
from tortoisehg.util import paths, debugthg, hglib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/util/editor.py b/tortoisehg/util/editor.py
--- a/tortoisehg/util/editor.py
+++ b/tortoisehg/util/editor.py
@@ -1,15 +1,14 @@
from __future__ import annotations

-import os, sys
+import os, sys, typing
from mercurial import (
match,
- pycompat,
util,
)

from mercurial.utils import procutil

-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/util/gpg.py b/tortoisehg/util/gpg.py
--- a/tortoisehg/util/gpg.py
+++ b/tortoisehg/util/gpg.py
@@ -8,10 +8,9 @@
from __future__ import annotations

import os
+import typing

-from . import hglib
-
-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Text,
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -78,9 +78,7 @@
raise NotImplementedError
# pytype: enable=import-error

-TYPE_CHECKING = getattr(pycompat, 'TYPE_CHECKING', False)
-
-if TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
AbstractSet,
Callable,
@@ -123,7 +121,7 @@
def ngettext(singular: str, plural: str, n: int) -> bytes:
return _ngettext(singular, plural, n).encode('utf-8')

-if TYPE_CHECKING:
+if typing.TYPE_CHECKING:
@overload
def tounicode(s: Union[bytes, pycompat.unicode]) -> pycompat.unicode:
pass
@@ -153,7 +151,7 @@
def to_unicode_list(seq: Iterable[Union[bytes, str]]) -> List[str]:
return cast(List[str], pycompat.maplist(tounicode, seq))

-if TYPE_CHECKING:
+if typing.TYPE_CHECKING:
@overload
def fromunicode(s: str, errors: str = 'strict') -> bytes:
pass
@@ -185,7 +183,7 @@
l = s.encode(_encoding, errors) # last ditch
return encoding.localstr(s.encode('utf-8'), l)

-if TYPE_CHECKING:
+if typing.TYPE_CHECKING:
@overload
def toutf(s: bytes) -> bytes:
pass
@@ -205,7 +203,7 @@
return s._utf8
return tounicode(s).encode('utf-8').replace(b'\0', b'')

-if TYPE_CHECKING:
+if typing.TYPE_CHECKING:
@overload
def fromutf(s: bytes) -> bytes:
pass
diff --git a/tortoisehg/util/menuthg.py b/tortoisehg/util/menuthg.py
--- a/tortoisehg/util/menuthg.py
+++ b/tortoisehg/util/menuthg.py
@@ -8,13 +8,14 @@
from __future__ import annotations

import os
+import typing

from mercurial import hg, error

from tortoisehg.util.i18n import _ as gettext
from tortoisehg.util import cachethg, paths, hglib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/util/paths.py b/tortoisehg/util/paths.py
--- a/tortoisehg/util/paths.py
+++ b/tortoisehg/util/paths.py
@@ -10,6 +10,7 @@
import os
import shlex
import sys
+import typing

import mercurial
from mercurial import (
@@ -31,7 +32,7 @@

_hg_command = None

-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/util/shlib.py b/tortoisehg/util/shlib.py
--- a/tortoisehg/util/shlib.py
+++ b/tortoisehg/util/shlib.py
@@ -10,6 +10,7 @@

import os
import time
+import typing

from hgext.largefiles import (
lfutil,
@@ -17,14 +18,13 @@

from mercurial import (
hg,
- pycompat,
)

from . import (
hglib,
)

-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/util/terminal.py b/tortoisehg/util/terminal.py
--- a/tortoisehg/util/terminal.py
+++ b/tortoisehg/util/terminal.py
@@ -1,11 +1,11 @@
from __future__ import annotations

-import os, sys
+import os, sys, typing
from mercurial import util
from mercurial.utils import procutil
from tortoisehg.util import hglib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
List,
Optional,
diff --git a/tortoisehg/util/typelib.py b/tortoisehg/util/typelib.py
--- a/tortoisehg/util/typelib.py
+++ b/tortoisehg/util/typelib.py
@@ -8,11 +8,9 @@

from __future__ import annotations

-from mercurial import (
- pycompat,
-)
+import typing

-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Dict,
List,
diff --git a/tortoisehg/util/wconfig.py b/tortoisehg/util/wconfig.py
--- a/tortoisehg/util/wconfig.py
+++ b/tortoisehg/util/wconfig.py
@@ -9,6 +9,7 @@

import os
import re
+import typing

from typing import (
Any,
@@ -26,7 +27,7 @@

from tortoisehg.util import hglib

-if hglib.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
Optional,
Union,
diff --git a/tortoisehg/util/win32ill.py b/tortoisehg/util/win32ill.py
--- a/tortoisehg/util/win32ill.py
+++ b/tortoisehg/util/win32ill.py
@@ -36,11 +36,10 @@

from __future__ import annotations

-import atexit, ctypes, os, threading
+import atexit, ctypes, os, threading, typing

from mercurial import (
error,
- pycompat,
)

from tortoisehg.util import (
@@ -49,7 +48,7 @@
)
from tortoisehg.util.i18n import agettext as _

-if pycompat.TYPE_CHECKING:
+if typing.TYPE_CHECKING:
from typing import (
BinaryIO,
Optional,

Matt Harbison

unread,
Mar 1, 2025, 9:56:05 PMMar 1
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1740865482 18000
# Sat Mar 01 16:44:42 2025 -0500
# Branch stable
# Node ID 6efd9a7016140555ea2809850426020cdc2c9461
# Parent b3577efbf1072cf247cbe1b69b0f8eab7b6be0c6
# EXP-Topic cleanup
packaging: bump py2exe to 0.11.1.1

This isn't the latest version, but the release notes for 0.12.0 talk about new
APIs and deprecating `setup.py py2exe`. That probably means overhauling both
`setup.py` like was done for Mercurial this cycle, as well as the packaging
code. Let's kick that can down the road.

In the meantime, this picks up important fixes like `sys.std{out,err}.write()`
returning the number of bytes written (per python3) instead of None.

diff --git a/contrib/packaging/requirements-windows-pyqt5-installer.txt b/contrib/packaging/requirements-windows-pyqt5-installer.txt
--- a/contrib/packaging/requirements-windows-pyqt5-installer.txt
+++ b/contrib/packaging/requirements-windows-pyqt5-installer.txt
@@ -1,6 +1,6 @@
#
-# This file is autogenerated by pip-compile with python 3.9
-# To update, run:
+# This file is autogenerated by pip-compile with Python 3.9
+# by the following command:
#
# pip-compile --generate-hashes --output-file=contrib/packaging/requirements-windows-pyqt5-installer.txt contrib/packaging/requirements-windows-pyqt5-installer.txt.in contrib/packaging/venv_py3/requirements.txt.in contrib/packaging/venv_py3/requirements_win32.txt.in
#
@@ -203,16 +203,16 @@
pefile==2021.9.3 \
--hash=sha256:344a49e40a94e10849f0fe34dddc80f773a12b40675bf2f7be4b8be578bdd94a
# via py2exe
-py2exe==0.11.1.0 \
- --hash=sha256:19e5d6803501fb55a30759889446234e275b2e5da21a53ae847e2529dd23eb7b \
- --hash=sha256:29707fbe1fe7670d6741cd1905bbf7368f1a5a98fa15524ef23aae2a88e4d465 \
- --hash=sha256:329bcf5f2feaf99b21c9ef49ec8060cfdcb5671debbab6f53135ae53d491fc4d \
- --hash=sha256:37fb1f7ff73e252bfa21789d8448d3bcf521a0bc1edd2ee3734534a4b437bed0 \
- --hash=sha256:7069b6ebc690f6f1b5ee8514a63f1c3765fa006cefc2e15aa306829b029b03a3 \
- --hash=sha256:85f29507dc426202bceec940fdf2fb7d566008406995760f99e8b3e7fe834d6a \
- --hash=sha256:9e29789b3e5a37fc376726062574607c9fe5ef88d0331d311871de4dda406717 \
- --hash=sha256:a03ba497f6eec4d0d41bd150ea611fb87db302a74a41d6826cb0445fdb418f41 \
- --hash=sha256:a9d42bc5c6120bda01fbba553215e3dee7d0d2951d6fe30fc7c36176a46ae0a9
+py2exe==0.11.1.1 \
+ --hash=sha256:04cb0b2f9ff4a443b6cde171a617f5b2306c1529cff58e90a8e046474abb2ca4 \
+ --hash=sha256:13962fef7b185fe7aaef3b857d925950b49e60b801e1cf995135c8fe146b2dd3 \
+ --hash=sha256:210018c7f99fa74f9542d7ef5248abc1e19e7deac706e600fdbbbf1aac09cc91 \
+ --hash=sha256:31423d29dfc767c9d523037f2b0c8c65343b600eb6cd7913a1e80e2e2edd4ca9 \
+ --hash=sha256:3811065e043e3f9a588320ace57403d8a97917c8fe0f51759da71960abc441c2 \
+ --hash=sha256:3b156daf52de3bc24261ff05969148460fc04cc50e17b207c6cb78fe193958a3 \
+ --hash=sha256:55daf0a721ebb3eeebccffc22e3402a72f485ba32b9a826c4a16199a65847d93 \
+ --hash=sha256:5e1786411b02854a4cbb1dd3e1d16f6ff1920457170b3f33a67ade1a76d00ed8 \
+ --hash=sha256:beacf6d496eab738d55df9701eb60623e11169993552d9cb8d1f20c279d2b323
# via -r contrib/packaging/requirements-windows-pyqt5-installer.txt.in
pycparser==2.21 \
--hash=sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9 \

Matt Harbison

unread,
Mar 1, 2025, 9:56:09 PMMar 1
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1740156227 18000
# Fri Feb 21 11:43:47 2025 -0500
# Branch stable
# Node ID 354e8327dea9ef5f541fd6bcb09ff18a3e1fb5fe
# Parent 6efd9a7016140555ea2809850426020cdc2c9461
# EXP-Topic cleanup
wix: drop the zope module reference

This dependency was removed in hg 7.0.

diff --git a/win32/wix/dist-py3.wxs b/win32/wix/dist-py3.wxs
--- a/win32/wix/dist-py3.wxs
+++ b/win32/wix/dist-py3.wxs
@@ -58,7 +58,6 @@
<File Name="mercurial.cext.osutil.pyd" />
<File Name="mercurial.cext.parsers.pyd" />
<File Name="mercurial.thirdparty.sha1dc.pyd" />
- <File Name="mercurial.thirdparty.zope.interface._zope_interface_coptimizations.pyd" />
<File Name="mercurial.zstd.pyd" />
<File Name="hgext.fsmonitor.pywatchman.bser.pyd" />
<File Name="pyexpat.pyd" />

Matt Harbison

unread,
Mar 1, 2025, 9:56:15 PMMar 1
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1740194154 18000
# Fri Feb 21 22:15:54 2025 -0500
# Branch stable
# Node ID b01d5bf24866da5fd2d2f39556c7f245c4a5ad49
# Parent 354e8327dea9ef5f541fd6bcb09ff18a3e1fb5fe
# EXP-Topic cleanup
packaging: adapt the Windows installer build to the core changes for PEP 517

The one thing we're missing here is the generated index for the extensions help.
That needs to be fixed in the hg build process, but there's also a bug since
hg 843418dc0b1b (March 2020) that seems to cause the index to be ignored by
py2exe altogether. So let's not worry about that for now.

There are also a few missing/added python packages by way of diffing `library.zip`
against the 6.9 installation, but they seem harmless.

The macOS installer still needs to be done.

diff --git a/contrib/packaging/thgpackaging/py2exe.py b/contrib/packaging/thgpackaging/py2exe.py
--- a/contrib/packaging/thgpackaging/py2exe.py
+++ b/contrib/packaging/thgpackaging/py2exe.py
@@ -239,25 +239,9 @@
env['PYTHONPATH'] = os.pathsep.join(path)

subprocess.run(
- [str(venv_python), 'setup.py', '--version'],
- cwd=str(hg_dir),
- env=env,
- check=True,
- )
- subprocess.run(
- [str(venv_python), 'setup.py', 'build_py', '-c', '-d', '.', 'build_mo'],
- cwd=str(hg_dir),
- env=env,
- check=True,
- )
- subprocess.run(
- [str(venv_python), 'setup.py', 'build_ext', '-i'],
- cwd=str(hg_dir),
- env=env,
- check=True,
- )
- subprocess.run(
- [str(venv_python), 'setup.py', 'build_hgextindex'],
+ # Need to use POSIX paths to prevent MSYS from dropping the '\'
+ # separators in the normal path.
+ ["make", "local", f"PYTHON={str(venv_python.as_posix())}"],
cwd=str(hg_dir),
env=env,
check=True,
@@ -265,7 +249,9 @@
subprocess.run(
# Use python_exe instead of venv_python so it has access to the docutils
# module in the bootstrap venv.
- [str(python_exe), 'setup.py', 'build_doc', '--html'],
+ # Need to use POSIX paths to prevent MSYS from dropping the '\'
+ # separators in the normal path.
+ ["make", "-C", "doc", "html", f"PYTHON={str(python_exe.as_posix())}"],
cwd=str(hg_dir),
env=env,
check=True,

Yuya Nishihara

unread,
Mar 2, 2025, 9:52:36 AMMar 2
to Matt Harbison, thg...@googlegroups.com
On Sat, 01 Mar 2025 21:55:45 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1735184634 18000
> # Wed Dec 25 22:43:54 2024 -0500
> # Branch stable
> # Node ID b3577efbf1072cf247cbe1b69b0f8eab7b6be0c6
> # Parent abb3512580cd16a371ac690863b56ef60657b028
> # EXP-Topic cleanup
> typing: convert (pycompat|hglib).TYPE_CHECKING to typing.TYPE_CHECKING

Queued, thanks.
Reply all
Reply to author
Forward
0 new messages