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, *values, 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, *values, 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(*, dir, progress_callback=None)[source]#
Bases:
object
Run commands directly on a Mercurial repository.
Lite, typed, pythonic wrapper for hg(1).
- Parameters:
dir (
Union
[str
,PathLike
[str
]]) β Operates as PATH in the corresponding hg subcommand.progress_callback (ProgressCallbackProtocol | None) β
Examples
>>> Hg(dir=tmp_path) <Hg dir=...>
- __init__(*, dir, progress_callback=None)[source]#
Lite, typed, pythonic wrapper for hg(1).
- Parameters:
dir (
Union
[str
,PathLike
[str
]]) β Operates as PATH in the corresponding hg subcommand.progress_callback (ProgressCallbackProtocol | None) β
- Return type:
None
Examples
>>> Hg(dir=tmp_path) <Hg dir=...>
-
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:
quiet (bool) β -q / βquiet
repository (str) β
--repository REPO
cwd (
libvcs._internal.types.StrOrBytesPath
, optional) β--cwd DIR
, Defaults tocwd
verbose (bool) β
-v / --verbose
non_interactive (bool) β
-y / --noninteractive
, defaults to Truecolor (HgColorTypeLiteral) β
--color
debug (bool) β
--debug
debugger (bool) β
--debugger
encoding (str) β
--encoding ENCODE
encoding_mode (str) β
--encodingmode MODE
traceback (bool) β
--traceback
time (bool) β
--time
profile (bool) β
--profile
version (bool) β
--version
help (bool) β
-h / --help
hidden (bool) β
--hidden
pager (HgPagerType) β
--pager TYPE
config (
Optional
[str
]) β--config CONFIG [+]
,section.name=value
check_returncode (bool, default:
True
) β Passthrough tolibvcs._internal.run.run()
args (str | bytes | PathLike[str] | PathLike[bytes] | Sequence[str | bytes | PathLike[str] | PathLike[bytes]]) β
kwargs (Any) β
- Return type:
Examples
>>> hg = Hg(dir=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.dir) if it doesnβt already exist.check_returncode (bool, default:
None
) β Passthrough toHg.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:
Examples
>>> hg = Hg(dir=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.dir.exists() True
- update(quiet=None, verbose=None, check_returncode=True, *args, **kwargs)[source]#
Update working directory.
Wraps hg update.
- Return type:
- Parameters:
Examples
>>> hg = Hg(dir=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:
- Parameters:
Examples
>>> hg = Hg(dir=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'