libvcs.sync.hg#

For mercurial, aka hg(1).

Mercurial Repo object for libvcs.

class libvcs.sync.hg.HgSync(*, url, dir, progress_callback=None, **kwargs)[source]#

Bases: BaseSync

Parameters:
  • progress_callback (func) –

    Retrieve live progress from sys.stderr (useful for certain vcs commands like git pull. Use progress_callback:

    >>> import os
    >>> import sys
    >>> def progress_cb(output, timestamp):
    ...     sys.stdout.write(output)
    ...     sys.stdout.flush()
    >>> class Project(BaseSync):
    ...     bin_name = 'git'
    ...     def obtain(self, *args, **kwargs):
    ...         self.ensure_dir()
    ...         self.run(
    ...             ['clone', '--progress', self.url, self.dir],
    ...             log_in_real_time=True
    ...         )
    >>> r = Project(
    ...     url=f'file://{create_git_remote_repo()}',
    ...     dir=str(tmp_path),
    ...     progress_callback=progress_cb
    ... )
    >>> r.obtain()
    Cloning into '...'...
    remote: Enumerating objects: ..., done...
    remote: Counting objects: 100% (...), done...
    remote: Total ... (delta 0), reused 0 (delta 0), pack-reused 0...
    Receiving objects: 100% (...), done...
    >>> assert r.dir.exists()
    >>> assert pathlib.Path(r.dir / '.git').exists()
    

  • url (str) –

  • dir (Path) –

  • kwargs (Any) –

bin_name: str = 'hg'#

VCS app name, e.g. β€˜git’

schemes: tuple[str, ...] = ('hg', 'hg+http', 'hg+https', 'hg+file')#

List of supported schemes to register in urlparse.uses_netloc

obtain(*args, **kwargs)[source]#
Return type:

None

Parameters:
  • args (Any) –

  • kwargs (Any) –

get_revision()[source]#
Return type:

str

update_repo(*args, **kwargs)[source]#
Return type:

None

Parameters:
  • args (Any) –

  • kwargs (Any) –