Skip to content

Commit 9d8c9a5

Browse files
committed
feat(cmd[hg]): Add pull
1 parent 1c36ea0 commit 9d8c9a5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/libvcs/cmd/hg.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,39 @@ def update(
275275
local_flags.append("--verbose")
276276

277277
return self.run(["update", *local_flags], check_returncode=check_returncode)
278+
279+
def pull(
280+
self,
281+
quiet: Optional[bool] = None,
282+
verbose: Optional[bool] = None,
283+
update: Optional[bool] = None,
284+
# libvcs special behavior
285+
check_returncode: Optional[bool] = True,
286+
*args: object,
287+
**kwargs: object,
288+
) -> str:
289+
"""Update working directory
290+
291+
Wraps `hg update <https://www.mercurial-scm.org/doc/hg.1.html#pull>`_.
292+
293+
Examples
294+
--------
295+
>>> hg = Hg(dir=tmp_path)
296+
>>> hg_remote_repo = create_hg_remote_repo()
297+
>>> hg.clone(url=f'file://{hg_remote_repo}')
298+
'updating to branch default...1 files updated, 0 files merged, ...'
299+
>>> hg.pull()
300+
'pulling from ...searching for changes...no changes found'
301+
>>> hg.pull(update=True)
302+
'pulling from ...searching for changes...no changes found'
303+
"""
304+
local_flags: list[str] = []
305+
306+
if quiet:
307+
local_flags.append("--quiet")
308+
if verbose:
309+
local_flags.append("--verbose")
310+
if update:
311+
local_flags.append("--update")
312+
313+
return self.run(["pull", *local_flags], check_returncode=check_returncode)

0 commit comments

Comments
 (0)