Expand description
The sync engine: source-agnostic glue between ReviewSource, RepoStore, and the Vcs
backends.
Workspaces are per stack, not per review: reviews whose ancestors chain them together (a
Phabricator stack) share one workspace, built from the stack’s tip, and a lone review is just a
stack of one. See stacks for how reviews are grouped.
rq sync (this module’s sync()) only ever tracks metadata and updates/removes existing
workspaces - it never creates one. Per source, per run:
fetch_queue()- reviews currently waiting on you.- New reviews are recorded with no workspace (see
fetch_local()for that); tracked ones get their metadata (includingversionandancestors) refreshed.
Then, once per source, for tracked reviews that weren’t in this run’s queue (you acted on
them - approved, requested changes - so they dropped out): fetch_status() tells us whether
the review itself resolved (landed/closed/abandoned/merged). A resolved review that isn’t part
of a workspace is just dropped.
Finally each existing workspace is reconciled against its stack: reviews newly chained onto a
checked-out stack join its workspace; a workspace whose tip or tip version changed is
updated in place if clean (update_workspace), or flagged if dirty; one whose reviews have
all resolved is removed, discarding any local changes. This is the only
workspace-removal path; there’s no separate prune step.
fetch_local() is the on-demand counterpart - resolving a canonical repo (asking before
cloning one, unless told otherwise) and creating a workspace for a single already-tracked
review’s stack, or, if it already has one, moving it to that review’s patch. It’s what rq fetch and the fetch hotkey in rq show’s TUI call; sync() never calls it itself.
Structs§
- Sync
Report - Workspace
Dirty - Returned by
remove_workspacewhen the workspace has local changes andforcewasn’t set. Callers should confirm with the user and retry withforce: trueif they agree to discard them.
Functions§
- fetch_
local - Resolve a canonical repo (asking before cloning one, unless
on_missingsays otherwise) and make surekey, a review already tracked by a priorsync(), has a workspace - the one for its whole stack - then move that workspace tokey’s own patch. If the stack is already checked out this is just the move (skipped when the workspace has local changes, which are never disturbed); anApplyFailedworkspace is instead cleaned up and rebuilt, since handing back a broken/empty path again would just repeat the failure silently. This is the on-demand counterpart tosync()’s deliberate refusal to create workspaces on its own - see the module docs. - remove_
workspace - Delete the local workspace of a review’s stack on demand - the
dhotkey inrq show’s TUI. Acts regardless ofresolved/in_queue, unlikesync()’s own resolved-and-clean removal path, and on every review in the stack, since they share the one workspace. - sync