Applying mailbox-style patches to a repository, similar to git am.
Supports state persistence in .git/rebase-apply/ for --continue, --skip, --abort, and --quit operations when a patch fails to apply.
| Class | |
Manages git am state on disk in .git/rebase-apply/. |
| Exception | |
Raised when a patch fails to apply during am. |
| Exception | |
Base class for am errors. |
| Function | am |
Apply patches from email messages to a repository, creating commits. |
| Function | am |
Abort the current am operation and restore the original state. |
| Function | am |
Continue applying patches after resolving a conflict. |
| Function | am |
Quit the current am operation without reverting changes. |
| Function | am |
Skip the current patch and continue with remaining patches. |
| Function | _apply |
Apply patches from start to total, cleaning up state on success. |
| Function | _apply |
Apply a single patch from state and create a commit. |
| Function | _get |
Undocumented |
| Function | _parse |
Parse an RFC 2822 date string into (timestamp, timezone_offset). |
| Function | _reset |
Hard-reset working tree and index to match a given tree. |
Repo, msgs: Iterable[ email.message.Message], *, three_way: bool = False, keep_subject: bool = False, keep_non_patch: bool = False, scissors: bool = False, message_id: bool = False, strip: int = 1, committer: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None) -> list[ ObjectID]:
¶
Apply patches from email messages to a repository, creating commits.
Saves state to .git/rebase-apply/ so that if a patch fails, the user can resolve and use am_continue(), am_skip(), am_abort(), or am_quit().
| Parameters | |
r:Repo | Repository object |
msgs:Iterable[ | Iterable of email.message.Message objects containing patches |
threebool | Fall back to 3-way merge if patch does not apply cleanly |
keepbool | If True, keep subject intact without munging |
keepbool | If True, only strip [PATCH] from brackets |
scissors:bool | If True, remove everything before scissors line |
messagebool | If True, include Message-ID in commit message |
strip:int | Number of leading path components to strip (default: 1) |
committer:bytes | None | Optional committer identity (bytes) |
commitfloat | None | Optional committer timestamp |
commitint | None | Optional committer timezone offset |
| Returns | |
list[ | List of commit SHAs (bytes) created |
| Raises | |
AmConflict | If a patch fails to apply (state is saved for recovery) |
AmError | If am state already exists (previous am in progress) |
Repo, *, committer: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None) -> list[ ObjectID]:
¶
Continue applying patches after resolving a conflict.
The user should have resolved conflicts in the working tree and staged the result before calling this.
| Parameters | |
r:Repo | Repository object |
committer:bytes | None | Optional committer identity |
commitfloat | None | Optional committer timestamp |
commitint | None | Optional committer timezone offset |
| Returns | |
list[ | List of commit SHAs created (for current + remaining patches) |
| Raises | |
AmError | If no am is in progress |
AmConflict | If a subsequent patch fails to apply |
Repo, *, committer: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None) -> list[ ObjectID]:
¶
Skip the current patch and continue with remaining patches.
Resets the working tree and index to HEAD before continuing.
| Parameters | |
r:Repo | Repository object |
committer:bytes | None | Optional committer identity |
commitfloat | None | Optional committer timestamp |
commitint | None | Optional committer timezone offset |
| Returns | |
list[ | List of commit SHAs created (for remaining patches) |
| Raises | |
AmError | If no am is in progress |
AmConflict | If a subsequent patch fails to apply |
Repo, state: DiskAmStateManager, start: int, total: int, *, committer: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None) -> list[ ObjectID]:
¶
Apply patches from start to total, cleaning up state on success.
| Raises | |
AmConflict | If a patch fails to apply (state preserved for recovery). |
Repo, state: DiskAmStateManager, patch_number: int, total: int, *, committer: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None) -> ObjectID:
¶
Apply a single patch from state and create a commit.
Returns the commit SHA.
| Raises | |
AmConflict | If the patch cannot be applied. |