rbtools.commands.patch¶
Implementation of rbt patch.
Classes
|
Applies a specific patch from a RB server. |
Information on a pending patch to apply. |
- class rbtools.commands.patch.PendingPatchInfo[source]¶
Bases:
TypedDict
Information on a pending patch to apply.
New in version 5.1.
- has_metadata: bool¶
Whether this patch contains scanned metadata.
This is
True
when an author and commit message could be determined.
- __closed__ = False¶
- __extra_items__ = None¶
- __mutable_keys__ = frozenset({'diff_revision', 'has_metadata', 'patch'})¶
- __optional_keys__ = frozenset({})¶
- __orig_bases__ = (<function TypedDict>,)¶
- __readonly_keys__ = frozenset({})¶
- __required_keys__ = frozenset({'diff_revision', 'has_metadata', 'patch'})¶
- __total__ = True¶
- class rbtools.commands.patch.PatchCommand(transport_cls: type[Transport] = <class 'rbtools.api.transport.sync.SyncTransport'>, stdout: TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, stderr: TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, stdin: TextIO = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>)[source]¶
Bases:
BaseCommand
Applies a specific patch from a RB server.
The patch file indicated by the request id is downloaded from the server and then applied locally.
- needs_api: ClassVar[bool] = True[source]¶
Whether the command needs the API client.
If this is set, the initialization of the command will set
api_client
andapi_root
.New in version 3.0.
- Type:
- needs_scm_client: ClassVar[bool] = True[source]¶
Whether the command needs the SCM client.
If this is set, the initialization of the command will set
repository_info
andtool
.New in version 3.0.
- Type:
- args: ClassVar[str] = '<review-request-id>'[source]¶
Usage text for what arguments the command takes.
Arguments for the command are anything passed in other than defined options (for example, revisions passed to rbt post).
- Type:
- option_list: ClassVar[list[Union[Option, OptionGroup]]] = [<rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.Option object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>][source]¶
Command-line options for this command.
- Type:
list
ofOption
orOptionGroup
- get_patches(*, diff_revision: Optional[int] = None, commit_ids: Optional[set[str]] = None, squashed: bool = False, reverted: bool = False) Sequence[PendingPatchInfo] [source]¶
Return the requested patches and their metadata.
If a diff revision is not specified, then this will look at the most recent diff.
- Parameters:
diff_revision (
int
, optional) –The diff revision to apply.
The latest revision will be used if not provided.
commit_ids (
list
ofunicode
, optional) –The specific commit IDs to apply.
If not specified, the squashed version of any commits (or the sole diff, in a non-multi-commit review request) will be applied.
squashed (
bool
, optional) – Whether to return a squashed version of the commits, if using a multi-commit review request.reverted (
bool
, optional) – Return patches in the order needed to revert them.
- Returns:
A list of dictionaries with patch information.
- Return type:
- Raises:
rbtools.command.CommandError – One of the following occurred: * The patch could not be retrieved or does not exist * The review request was created without history support and
commit_ids
was provided. * One or more requested commit IDs could not be found.
- initialize() None [source]¶
Initialize the command.
This overrides
BaseCommand.initialize
in order to handle full review request URLs on the command line. In this case, we want to parse that URL in order to pull the server name and diff revision out of it.- Raises:
rbtools.commands.CommandError – A review request URL passed in as the review request ID could not be parsed correctly or included a bad diff revision.