12
12
from collections .abc import Sequence
13
13
from typing import Any , Optional , Union
14
14
15
- from libvcs ._internal .run import run
15
+ from libvcs ._internal .run import ProgressCallbackProtocol , run
16
16
from libvcs ._internal .types import StrOrBytesPath , StrPath
17
17
18
18
_CMD = Union [StrOrBytesPath , Sequence [StrOrBytesPath ]]
@@ -34,7 +34,14 @@ class HgPagerType(enum.Enum):
34
34
35
35
36
36
class Hg :
37
- def __init__ (self , * , dir : StrPath ) -> None :
37
+ progress_callback : Optional [ProgressCallbackProtocol ] = None
38
+
39
+ def __init__ (
40
+ self ,
41
+ * ,
42
+ dir : StrPath ,
43
+ progress_callback : Optional [ProgressCallbackProtocol ] = None ,
44
+ ) -> None :
38
45
"""Lite, typed, pythonic wrapper for hg(1).
39
46
40
47
Parameters
@@ -54,6 +61,8 @@ def __init__(self, *, dir: StrPath) -> None:
54
61
else :
55
62
self .dir = pathlib .Path (dir )
56
63
64
+ self .progress_callback = progress_callback
65
+
57
66
def __repr__ (self ) -> str :
58
67
return f"<Hg dir={ self .dir } >"
59
68
@@ -171,6 +180,9 @@ def run(
171
180
if help is True :
172
181
cli_args .append ("--help" )
173
182
183
+ if self .progress_callback is not None :
184
+ kwargs ["callback" ] = self .progress_callback
185
+
174
186
return run (
175
187
args = cli_args ,
176
188
check_returncode = True if check_returncode is None else check_returncode ,
0 commit comments