Skip to main content

apply-patch Command

Apply a patch from a unified diff file or cherry-pick an existing patch operation to a different base snapshot.

Usage

batho apply-patch --root /path/to/repo --base-snapshot SNAPSHOT_ID [options]

Flags

FlagDefaultDescription
--rootrequiredPath to repository root
--base-snapshotrequiredBase snapshot ID to apply patch to
--diff-filenonePath to unified diff file
--patch-idnonePatch operation ID to cherry-pick
--dry-runoffPreview without applying

Examples

Apply from Diff File

# Apply patch from unified diff
batho apply-patch --root . \
--base-snapshot batho_project_abc123_20260501T100000Z \
--diff-file changes.diff

# Preview before applying
batho apply-patch --root . \
--base-snapshot batho_project_abc123_20260501T100000Z \
--diff-file changes.diff \
--dry-run

Cherry-pick Existing Patch

# Cherry-pick a patch to different snapshot
batho apply-patch --root . \
--base-snapshot batho_project_new_20260520T100000Z \
--patch-id batho_uuid_20260517T120000Z

# Preview cherry-pick
batho apply-patch --root . \
--base-snapshot batho_project_new_20260520T100000Z \
--patch-id batho_uuid_20260517T120000Z \
--dry-run

Diff File Format

The diff file should be in unified diff format:

--- a/src/auth.py
+++ b/src/auth.py
@@ -10,5 +10,7 @@
def login(username, password):
+ """Authenticate user."""
if validate(username, password):
return True
+ log_attempt(username)
return False

Use Cases

  • Replay changes: Apply the same diff to a different snapshot
  • Cherry-pick: Apply a specific patch to a different branch/snapshot
  • Testing: Verify patches work on different base states
  • Migration: Move changes between snapshot lineages
  • patch - Apply incremental patches via scan or diff
  • cherry-pick - Dedicated cherry-pick command
  • patch-info - Show patch details before applying