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=<not given>, *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=<not given>, *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(*, path, progress_callback=None)[source]¶
Bases:
object
Run commands directly on a Mercurial repository.
Lite, typed, pythonic wrapper for hg(1).
- Parameters:
path (
Union
[str
,PathLike
[str
]]) – Operates as PATH in the corresponding hg subcommand.progress_callback (ProgressCallbackProtocol | None)
Examples
>>> Hg(path=tmp_path) <Hg path=...>
- __init__(*, path, progress_callback=None)[source]¶
Lite, typed, pythonic wrapper for hg(1).
- Parameters:
path (
Union
[str
,PathLike
[str
]]) – Operates as PATH in the corresponding hg subcommand.progress_callback (ProgressCallbackProtocol | None)
- 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:
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(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 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(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:
- 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:
- 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'