monopam: add --path for partial views of an upstream monorepo
Enable "one global library monorepo + many local product monorepos"
and "two developers sharing a subset of one upstream mono" workflows
by letting monopam add materialize just a subdirectory of a larger
source repo as a local subtree.
monopam add file://upstream.git --path eio
imports only the eio/ subtree of upstream.git into the local mono.
sources.toml gains a per-entry path field that records the split
location, so pull and push know which subdirectory to round-trip.
Implementation:
- Sources_registry.entry gets a new path: string option. TOML codec
reads/writes the field; legacy sources.toml without it loads with
path = None.
- Import.git_url, with a path argument, fetches the upstream full,
calls Git.Subtree.split at the path to get a standalone history,
then Git.Subtree.add that split at the local subtree name. Default
local name becomes the path basename.
- Push.one branches on the entry's path field. For path entries it
calls merge_split_into_path, which splits the local mono,
push_refspecs the split into the checkout (a full clone of the
source), Git.Subtree.merge-s at the path, then lets the existing
to_upstream step push the checkout back to the source. After the
merge it uses Git.Repository.checkout + add_all to sync the
worktree and index.
- Pull.subtree likewise branches on path: fetch the checkout,
Git.Subtree.split at the path, merge into the local mono at the
local prefix.
- Both sites look up sources.toml entries by package name OR repo
name. Previously the lookup used Package.subtree_prefix, which for
path entries is the source repo name ("global"), not the local
subtree name ("eio").
Side fix: Tty.Span.pp used to always emit ANSI even with NO_COLOR
set. vlog already runs Fmt_cli.style_renderer and
Fmt_tty.setup_std_outputs to honor --color; this patch adds a
--no-color cmdliner flag backed by a NO_COLOR Cmd.Env.info to vlog
and forces the style renderer to None when set. Span.render now
consults Fmt.style_renderer on the target formatter instead of a
separate global toggle — single source of truth for colour across
the tree.
Tests:
- monopam/test/subtree_path.t exercises the full path round-trip:
add --path eio, add --path cohttp, edit eio locally, push, verify
global.git received only the eio change, pull a third-party edit,
verify the local mono gets it with cohttp untouched.