libvcs.cmd.hg¶

For mercurial, aka hg(1).

Run hg (Mercurial) commands directly against a local mercurial repo.

Note

At a Mercurial shop? Can you help us jimmy this module into the next Sunbeam toaster of Mercurialian perfection? We need to patch and shimmy this thing into shape and seek a skilled tradesperson to give it - in Robert M. Pirsig’s sense - care. Connect with us on the tracker. It’s not too late to change the API.

class libvcs.cmd.hg.HgColorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

CLI Color enum for Mercurial.

boolean = 'boolean'¶
always = 'always'¶
auto = 'auto'¶
never = 'never'¶
debug = 'debug'¶
class libvcs.cmd.hg.HgPagerType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

CLI Pagination enum for Mercurial.

boolean = 'boolean'¶
always = 'always'¶
auto = 'auto'¶
never = 'never'¶
class libvcs.cmd.hg.Hg(*, path, progress_callback=None)[source]¶

Bases: object

Run commands directly on a Mercurial repository.

Lite, typed, pythonic wrapper for hg(1).

Parameters:

Examples

>>> Hg(path=tmp_path)
<Hg path=...>
__init__(*, path, progress_callback=None)[source]¶

Lite, typed, pythonic wrapper for hg(1).

Parameters:
Return type:

None

Examples

>>> Hg(path=tmp_path)
<Hg path=...>
path: Path¶

Directory to check out

progress_callback: Optional[ProgressCallbackProtocol] = None¶
run(args, *, config=None, repository=None, quiet=None, _help=None, encoding=None, encoding_mode=None, verbose=None, traceback=None, debug=None, debugger=None, profile=None, version=None, hidden=None, time=None, pager=None, color=None, check_returncode=None, **kwargs)[source]¶

Run a command for this Mercurial repository.

Passing None to a subcommand option, the flag won’t be passed unless otherwise stated.

hg help and hg help [cmd]

Wraps hg’s Options.

Parameters:
Return type:

str

Examples

>>> hg = Hg(path=tmp_path)
>>> hg.run(['help'])
"Mercurial Distributed SCM..."
clone(*, url, no_update=None, update_rev=None, rev=None, branch=None, ssh=None, remote_cmd=None, pull=None, stream=None, insecure=None, quiet=None, make_parents=True, check_returncode=None)[source]¶

Clone a working copy from a mercurial repo.

Wraps hg clone.

Parameters:
  • make_parents (bool, default: True) – Creates checkout directory (:attr:`self.path) if it doesn’t already exist.

  • check_returncode (bool, default: None) – Passthrough to Hg.run()

  • url (str)

  • no_update (bool | None)

  • update_rev (str | None)

  • rev (str | None)

  • branch (str | None)

  • ssh (str | None)

  • remote_cmd (str | None)

  • pull (bool | None)

  • stream (bool | None)

  • insecure (bool | None)

  • quiet (bool | None)

Return type:

str

Examples

>>> hg = Hg(path=tmp_path)
>>> hg_remote_repo = create_hg_remote_repo()
>>> hg.clone(url=f'file://{hg_remote_repo}')
'updating to branch default...1 files updated, 0 files merged, ...'
>>> hg.path.exists()
True
update(quiet=None, verbose=None, check_returncode=True, *args, **kwargs)[source]¶

Update working directory.

Wraps hg update.

Return type:

str

Parameters:

Examples

>>> hg = Hg(path=tmp_path)
>>> hg_remote_repo = create_hg_remote_repo()
>>> hg.clone(url=f'file://{hg_remote_repo}')
'updating to branch default...1 files updated, 0 files merged, ...'
>>> hg.update()
'0 files updated, 0 files merged, 0 files removed, 0 files unresolved'
pull(quiet=None, verbose=None, update=None, check_returncode=True, *args, **kwargs)[source]¶

Update working directory.

Wraps hg update.

Return type:

str

Parameters:

Examples

>>> hg = Hg(path=tmp_path)
>>> hg_remote_repo = create_hg_remote_repo()
>>> hg.clone(url=f'file://{hg_remote_repo}')
'updating to branch default...1 files updated, 0 files merged, ...'
>>> hg.pull()
'pulling from ...searching for changes...no changes found'
>>> hg.pull(update=True)
'pulling from ...searching for changes...no changes found'