Skip to content

Commit ec17ada

Browse files
committed
refactor(cmd[hg]): Pass-through progress_callback
1 parent 8f7b27c commit ec17ada

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/libvcs/cmd/hg.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from collections.abc import Sequence
1313
from typing import Any, Optional, Union
1414

15-
from libvcs._internal.run import run
15+
from libvcs._internal.run import ProgressCallbackProtocol, run
1616
from libvcs._internal.types import StrOrBytesPath, StrPath
1717

1818
_CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
@@ -34,7 +34,14 @@ class HgPagerType(enum.Enum):
3434

3535

3636
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:
3845
"""Lite, typed, pythonic wrapper for hg(1).
3946
4047
Parameters
@@ -54,6 +61,8 @@ def __init__(self, *, dir: StrPath) -> None:
5461
else:
5562
self.dir = pathlib.Path(dir)
5663

64+
self.progress_callback = progress_callback
65+
5766
def __repr__(self) -> str:
5867
return f"<Hg dir={self.dir}>"
5968

@@ -171,6 +180,9 @@ def run(
171180
if help is True:
172181
cli_args.append("--help")
173182

183+
if self.progress_callback is not None:
184+
kwargs["callback"] = self.progress_callback
185+
174186
return run(
175187
args=cli_args,
176188
check_returncode=True if check_returncode is None else check_returncode,

0 commit comments

Comments
 (0)