Sync helpers

Warning

Be careful with these! Internal APIs are not covered by version policies. They can break or be removed between minor versions!

If you need an internal API stabilized please file an issue.

vcspull._internal.sync translates validated checkout configuration into typed libvcs backend instances, target selectors, sync policies, and structured recovery payloads.

Shared checkout settings and sync outcomes for CLI commands.

class vcspull._internal.sync.SyncExecution
class vcspull._internal.sync.SyncExecution

Bases: object

Keep the backend instance and its complete synchronization result.

vcspull._internal.sync.create_sync_project(repo, *, vcs, progress_callback=None)
function[source]
function[source]
vcspull._internal.sync.create_sync_project(repo, *, vcs, progress_callback=None)

Construct a typed backend without accessing or changing its checkout.

Parameters:
Return type:

BaseSync

vcspull._internal.sync.checkout_settings(config, *, worktree=False)
function[source]
function[source]
vcspull._internal.sync.checkout_settings(config, *, worktree=False)

Translate a validated checkout without collapsing its selector kind.

>>> target, policy = checkout_settings({"tag": "v1", "sync": {"drift": "keep"}})
>>> target.tag, policy.drift
('v1', 'keep')
>>> checkout_settings(None)
(None, SyncPolicy(drift='follow', dirty='abort'))
Parameters:
Return type:

tuple[SyncTarget | None, SyncPolicy]

vcspull._internal.sync.sync_result_data(result)
function[source]
function[source]
vcspull._internal.sync.sync_result_data(result)

Serialize recovery identity and outcomes without exception objects.

>>> sync_result_data(SyncResult())["preservation_state"]
'not-needed'
Parameters:

result (SyncResult)

Return type:

dict[str, Any]

vcspull._internal.sync.format_recovery_lines(primary, retained=())
function[source]
function[source]
vcspull._internal.sync.format_recovery_lines(primary, retained=())

Render deduplicated recovery, conflict, and inspection lines.

>>> token = RecoveryToken("tok-1", "git", "/tmp/store/tok-1")
>>> res = SyncResult(
...     recovery=token,
...     update_state="completed",
...     preservation_state="restored",
... )
>>> format_recovery_lines(res)
['Update: completed; local changes: restored', 'Recovery retained (git): tok-1 ...']
Parameters:
  • primary (SyncResult | None)

  • retained (Sequence[SyncResult])

Return type:

list[str]

vcspull._internal.sync.require_discard_authorization(policy, *, allow_discard)
function[source]
function[source]
vcspull._internal.sync.require_discard_authorization(policy, *, allow_discard)

Require explicit invocation consent before constructing a discard backend.

Parameters:
  • policy (SyncPolicy)

  • allow_discard (bool)

Return type:

None