Show More
@@ -19,6 +19,10 b' import subprocess' | |||
|
19 | 19 | import sys |
|
20 | 20 | import traceback |
|
21 | 21 | |
|
22 | from typing import ( | |
|
23 | Optional, | |
|
24 | ) | |
|
25 | ||
|
22 | 26 | from .i18n import _ |
|
23 | 27 | from .node import hex |
|
24 | 28 | from .pycompat import ( |
@@ -2057,7 +2061,7 b' class ui:' | |||
|
2057 | 2061 | ) |
|
2058 | 2062 | |
|
2059 | 2063 | @util.propertycache |
|
2060 | def _progbar(self): | |
|
2064 | def _progbar(self) -> Optional[progress.progbar]: | |
|
2061 | 2065 | """setup the progbar singleton to the ui object""" |
|
2062 | 2066 | if ( |
|
2063 | 2067 | self.quiet |
@@ -2068,14 +2072,16 b' class ui:' | |||
|
2068 | 2072 | return None |
|
2069 | 2073 | return getprogbar(self) |
|
2070 | 2074 | |
|
2071 | def _progclear(self): | |
|
2075 | def _progclear(self) -> None: | |
|
2072 | 2076 | """clear progress bar output if any. use it before any output""" |
|
2073 | 2077 | if not haveprogbar(): # nothing loaded yet |
|
2074 | 2078 | return |
|
2075 | 2079 | if self._progbar is not None and self._progbar.printed: |
|
2076 | 2080 | self._progbar.clear() |
|
2077 | 2081 | |
|
2078 | def makeprogress(self, topic, unit=b"", total=None): | |
|
2082 | def makeprogress( | |
|
2083 | self, topic: bytes, unit: bytes = b"", total: Optional[int] = None | |
|
2084 | ) -> scmutil.progress: | |
|
2079 | 2085 | """Create a progress helper for the specified topic""" |
|
2080 | 2086 | if getattr(self._fmsgerr, 'structured', False): |
|
2081 | 2087 | # channel for machine-readable output with metadata, just send |
@@ -2249,10 +2255,10 b' class ui:' | |||
|
2249 | 2255 | |
|
2250 | 2256 | # we instantiate one globally shared progress bar to avoid |
|
2251 | 2257 | # competing progress bars when multiple UI objects get created |
|
2252 | _progresssingleton = None | |
|
2258 | _progresssingleton: Optional[progress.progbar] = None | |
|
2253 | 2259 | |
|
2254 | 2260 | |
|
2255 | def getprogbar(ui): | |
|
2261 | def getprogbar(ui: ui) -> progress.progbar: | |
|
2256 | 2262 | global _progresssingleton |
|
2257 | 2263 | if _progresssingleton is None: |
|
2258 | 2264 | # passing 'ui' object to the singleton is fishy, |
@@ -2261,7 +2267,7 b' def getprogbar(ui):' | |||
|
2261 | 2267 | return _progresssingleton |
|
2262 | 2268 | |
|
2263 | 2269 | |
|
2264 | def haveprogbar(): | |
|
2270 | def haveprogbar() -> bool: | |
|
2265 | 2271 | return _progresssingleton is not None |
|
2266 | 2272 | |
|
2267 | 2273 |
General Comments 0
You need to be logged in to leave comments.
Login now