The mitch repository is now developed with Jujutsu (jj), colocated with git, and other codebases that use mitch may follow. mitch checkout and mitch stash only know git and Mercurial. In a colocated jj repository they find .git and drive git directly: git checkout moves HEAD behind jj's back, and git stash keeps local changes in a place jj does not know about. What jj makes of that is untested and at best surprising, and a non-colocated jj repository is not detected at all.
Solution
A third version-control backend for Jujutsu, implementing VersionControlManagerProtocol in src/mitch/vcs.py, so that checkout and stash keep the database in step when switching revisions with jj.
Detection..jj at or above the project root selects the jj backend. In a colocated repository (.jj and .git) jj wins, because jj owns the working copy there. --vcs jj selects it explicitly.
Revisions. The target of mitch checkout is a jj revision: a bookmark, a change ID, a commit ID or a revset that resolves to exactly one revision.
A possible mapping of the protocol, to be confirmed in design:
Protocol method
jj
repository_root
jj root
is_dirty
jj diff -r @ --summary is not empty (jj snapshots the working copy and tracks new files automatically)
can_checkout
jj log -r <rev> --no-graph -T commit_id resolves to exactly one revision
checkout
jj new <rev>, or jj edit <rev> (see open questions)
stash_changes / restore_changes / stashed
jj has no stash. Local changes already live in the working-copy commit @; see open questions
materialized(revision)
write jj file list -r <rev> / jj file show -r <rev> <path> into a temporary directory
path_changed(branch, path)
jj diff --from <current> --to <rev> --summary <path> is not empty
Open Questions
What is "the current commit"? The git backend compares HEAD with the target. In jj the working-copy commit @ holds the local changes, so the committed state is @-, unless @ is a described change the developer is still working on. Which one does checkout plan from?
Checkout with local changes. jj's natural move is jj rebase -r @ -d <rev>: the working-copy commit with its changes travels to the target. That differs from stash–checkout–pop, and may conflict. Alternatively jj new <rev> leaves the changes behind in the old commit. Which does --allow-dirty mean for jj, and does mitch stash make sense at all with jj?
jj new or jj edit?new starts an empty change on top of the target, edit makes the target itself the working copy, so later edits amend it.
Submodules. jj does not support git submodules; linked projects in submodules may not be checked out. Is the warning about changed linked projects enough?
Mercurial-style forges. ourforge tracks changes by identity across rebases. Does checkout need anything beyond plain revisions, such as checking out a topic or a merge-request stack?
Testing Decisions
Same seam as the existing checkout tests (tests/test_checkout_hg.py, tests/test_cli.py): the CLI in-process against SQLite files and a jj repository created under the test's temporary directory.
Skip the jj tests when jj is not installed.
Cover both a colocated and a non-colocated repository, a clean and a dirty working copy, checkout across a rework (ADR cli/checkout/transition-plan-compares-ids-and-hashes), and the v2-to-v1 regression case from ADR cli/checkout/restore-applied-migrations-but-do-not-up.
Out of Scope
Using jj for anything other than checkout and stash.
Fetching or updating linked projects (ADR project/code-delivery-is-out-of-scope).