Skip to content

Commit 1c36ea0

Browse files
committed
feat(cmd[hg]): check_returncode, quiet, verbose
1 parent 59be5a1 commit 1c36ea0

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

src/libvcs/cmd/hg.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def run(
7777
time: Optional[bool] = None,
7878
pager: Optional[HgPagerType] = None,
7979
color: Optional[HgColorType] = None,
80+
check_returncode: Optional[bool] = None,
8081
**kwargs: Any,
8182
) -> str:
8283
"""
@@ -125,6 +126,8 @@ def run(
125126
``--pager TYPE``
126127
config :
127128
``--config CONFIG [+]``, ``section.name=value``
129+
check_returncode : bool, default: ``True``
130+
Passthrough to :func:`libvcs._internal.run.run()`
128131
129132
Examples
130133
--------
@@ -150,7 +153,7 @@ def run(
150153
if color is not None:
151154
cli_args.append(["--color", color])
152155
if verbose is True:
153-
cli_args.append("verbose")
156+
cli_args.append("--verbose")
154157
if quiet is True:
155158
cli_args.append("--quiet")
156159
if debug is True:
@@ -168,7 +171,11 @@ def run(
168171
if help is True:
169172
cli_args.append("--help")
170173

171-
return run(args=cli_args, **kwargs)
174+
return run(
175+
args=cli_args,
176+
check_returncode=True if check_returncode is None else check_returncode,
177+
**kwargs,
178+
)
172179

173180
def clone(
174181
self,
@@ -183,8 +190,10 @@ def clone(
183190
pull: Optional[bool] = None,
184191
stream: Optional[bool] = None,
185192
insecure: Optional[bool] = None,
193+
quiet: Optional[bool] = None,
186194
# Special behavior
187195
make_parents: Optional[bool] = True,
196+
check_returncode: Optional[bool] = None,
188197
) -> str:
189198
"""Clone a working copy from a mercurial repo.
190199
@@ -194,6 +203,8 @@ def clone(
194203
----------
195204
make_parents : bool, default: ``True``
196205
Creates checkout directory (`:attr:`self.dir`) if it doesn't already exist.
206+
check_returncode : bool, default: ``None``
207+
Passthrough to :meth:`Hg.run`
197208
198209
Examples
199210
--------
@@ -223,15 +234,26 @@ def clone(
223234
local_flags.append("--stream")
224235
if insecure is True:
225236
local_flags.append("--insecure")
237+
if quiet is True:
238+
local_flags.append("--quiet")
226239

227240
# libvcs special behavior
228241
if make_parents and not self.dir.exists():
229242
self.dir.mkdir(parents=True)
230243
return self.run(
231-
["clone", *local_flags, "--", *required_flags], check_returncode=False
244+
["clone", *local_flags, "--", *required_flags],
245+
check_returncode=check_returncode,
232246
)
233247

234-
def update(self) -> str:
248+
def update(
249+
self,
250+
quiet: Optional[bool] = None,
251+
verbose: Optional[bool] = None,
252+
# libvcs special behavior
253+
check_returncode: Optional[bool] = True,
254+
*args: object,
255+
**kwargs: object,
256+
) -> str:
235257
"""Update working directory
236258
237259
Wraps `hg update <https://www.mercurial-scm.org/doc/hg.1.html#update>`_.
@@ -247,4 +269,9 @@ def update(self) -> str:
247269
"""
248270
local_flags: list[str] = []
249271

250-
return self.run(["update", *local_flags], check_returncode=False)
272+
if quiet:
273+
local_flags.append("--quiet")
274+
if verbose:
275+
local_flags.append("--verbose")
276+
277+
return self.run(["update", *local_flags], check_returncode=check_returncode)

0 commit comments

Comments
 (0)