Support numeric depth: N and move per-repo sync keys under options:#554
Merged
Conversation
why: libvcs 0.42.0 adds an arbitrary GitSync clone depth (depth=N) and fixes a constructor bug that dropped git_shallow/tls_verify. vcspull needs the depth argument to persist and apply a numeric depth: N per repository (issue #552); the prior <0.42.0 pin cannot honor it. what: - Bump the libvcs dependency floor to >=0.42.0,<0.43.0 - Relock uv.lock (libvcs 0.41.0 -> 0.42.0)
…epth helpers why: Issue #552 adds a numeric clone depth and relocates the per-repo sync-tuning keys (rev/shallow/depth) into the existing options: block, keeping them out of the entry root. The reader must accept the new canonical form while still honoring v1.61.0's top-level keys, and the add/discover/migrate paths need shared primitives for depth. what: - types: add rev/shallow/depth to RepoOptionsDict; add depth to ConfigDict; mark top-level rev/shallow in RepoEntryDict as deprecated - config.extract_repos: lift options.{rev,shallow,depth} onto the flat ConfigDict (options wins over a legacy top-level key) - config.detect_git_depth: report a shallow checkout's commit count - config.resolve_clone_depth: shared hybrid precedence for add/discover - config.migrate_repo_entry: relocate legacy top-level keys under options: (depth wins over shallow) - config.detect_legacy_repo_options: find entries still using top-level keys (drives the deprecation warning) - tests: cover the reader, helpers, and migration with parametrized NamedTuple fixtures
why: Issue #552 lets workspaces keep a small history window (e.g. --depth 50) instead of only the boolean shallow flag, and relocates the per-repo sync keys into options:. libvcs 0.42.0 honors GitSync(depth=N), so add/discover can persist it and sync can apply it. what: - build_repo_entry: nest rev/shallow/depth under options:; depth wins over shallow - add: add --depth N (validated >=1); resolve_clone_depth replaces the inline shallow check (hybrid auto-detect); thread depth to add_repo - discover: add --depth N; carry depth on _FoundRepo; per-repo resolve_clone_depth; log and persist depth - sync.update_repo: apply options.depth as GitSync.depth (git-gated, depth wins); refresh the git_shallow comment for libvcs 0.42.0 - sync: load_configs(warn_legacy_options=True) warns on top-level rev/shallow/depth and points at vcspull migrate - tests: depth cases for add/discover, sync depth + deprecation-warning coverage; existing assertions moved to the options: form
why: Moving rev/shallow/depth under options: deprecates the v1.61.0 top-level keys. Users need a one-shot, idempotent rewrite of existing configs rather than hand-editing, and sync only warns about the old form. what: - Add `vcspull migrate` (mirrors fmt: -f/--file, --write, --all), reusing config.migrate_repo_entry; dry-run previews, --write rewrites - Register the subparser and dispatch arm in the CLI - Extend the CLI logger-names expectation for the new module - tests: migrate_config relocation matrix, write/dry-run, idempotency, and an end-to-end CLI run
why: The per-repo sync keys now live under options:, depth: N is new, and the top-level form is deprecated. Users need the canonical shape, the precedence rules, and the migration path documented. what: - configuration: group rev/shallow/depth under an "options:" section, add a clone-depth section, and document migrating off the top-level form via vcspull migrate - cli: add the vcspull migrate page (grid, toctree, see-also) and its API automodule page
why: Record the user-facing add/discover/sync/migrate changes for the unreleased 1.61 line. what: - Add "Numeric clone depth" (#552) deliverable - Add "Migrate configs to the options: form" (#552) deliverable - Note the libvcs>=0.42.0 floor and the deprecation of top-level rev/shallow/depth with a before/after migration path
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #554 +/- ##
==========================================
- Coverage 83.69% 82.82% -0.88%
==========================================
Files 29 30 +1
Lines 4159 4354 +195
Branches 820 873 +53
==========================================
+ Hits 3481 3606 +125
- Misses 442 502 +60
- Partials 236 246 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
why: Users on v1.61.0 wrote top-level rev/shallow keys; they need a migration note telling them the form changed, that the old keys still load but warn, and how to rewrite configs. what: - Add a 'Next release' entry covering the rev/shallow/depth move under options:, with before/after YAML and the vcspull migrate --write step - Mention depth: N as the new numeric clone-depth key
why: The migration story spans three pages (config schema, the migrate command, and the migration notes); readers landing on one had no path to the others. what: - Link the configuration migration subsection to the migration notes - Add a 'See also' on the migrate command page pointing to the config schema and the migration notes
why: Only a single shape (top-level shallow) proved the legacy-format warning; the rev/depth/combo/multi paths and the negative cases (canonical options:, string shorthand) were unverified. what: - Replace the single test with a NamedTuple + test_id matrix over load_configs(warn_legacy_options=True) - Cover rev/shallow/depth/combo and multi-entry (assert affected count parsed from the message), plus canonical and string entries that must NOT warn - Assert on caplog.records schema (level, vcspull_config_path, message)
…ing text
why: The deprecation-warning test counted affected entries by parsing the
rendered log message ("Affected: ...".split), which couples the test to
message formatting. The project standard is to assert on structured
record attributes, not the message string.
what:
- Carry the affected-entry count as a scalar `vcspull_legacy_count` in the
warning's `extra` (alongside `vcspull_config_path`)
- Assert `record.vcspull_legacy_count == affected_count`; narrow the record
filter on both extras so the access stays type-checked
…ment why: The comment omitted the actual reason for applying the keys post-construction (libvcs names shallow `git_shallow`, so it must be translated) and overstated "leaking git-only kwargs into the svn/hg sync constructors" — HgSync/SvnSync absorb unknown **kwargs harmlessly, so that was never the failure mode. what: - State the real rationale: translate shallow->git_shallow, apply both as attributes for git only, and let obtain() resolve precedence - Comment-only; no behavior change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
options.depth: Nper-repository key (and--depth Nonadd/discover) so workspaces can keep a small window of history instead of the all-or-nothingshallow: true. Resolves add/discover: support numeric depth: N (follow-up to #550) #552.options.shallow: true, a deeper window recordsoptions.depth: N.rev,shallow, anddepthunder anoptions:block (joining the existingpin/pin_reason), so VCS-sync tuning and mutation policy share one namespace.vcspull migratesubcommand that rewrites configs from the deprecated top-level form intooptions:.rev:/shallow:keys that shipped in v1.61.0 — they are still read, andvcspull syncwarns and points atvcspull migrate.libvcs>=0.42.0, which honors an arbitraryGitSync(depth=N).Changes by area
Dependencies
pyproject.toml/uv.lock: bump the floor tolibvcs>=0.42.0,<0.43.0.Schema & config (
src/vcspull/types.py,src/vcspull/config.py)RepoOptionsDict: now carriesrev/shallow/depthalongsidepin/pin_reason;RepoEntryDictmarks the top-levelrev/shallowas deprecated;ConfigDictgainsdepth.extract_repos: liftsoptions.{rev,shallow,depth}onto the flat internal config; anoptions:value wins over a legacy top-level key, so the sync path is unchanged apart fromdepth.detect_git_depth: reports a shallow checkout's commit count.resolve_clone_depth: the shared hybrid precedence used byaddanddiscover(explicit--depth→ explicit--shallow→ auto-detect).migrate_repo_entry/detect_legacy_repo_options: relocate top-level keys underoptions:(depth wins over shallow) and scan a raw config for entries still using the old form.CLI (
add,discover,sync)add/discover: add--depth N(validated>= 1); record sync keys underoptions:via a sharedbuild_repo_entry; log the recordeddepth/shallow.sync: appliesoptions.depthasGitSync.depth(git-only, depth wins over shallow), and warns when it loads a config still using top-level keys.Migrate command (
src/vcspull/cli/migrate.py)vcspull migrate: mirrorsfmt(-f/--file,--write,--all). Previews by default, rewrites with--write, and is idempotent.Docs
docs/configuration/: anoptions:"Sync options" section (rev/shallow/depth), a clone-depth section, and a migration note.docs/cli/migrate.md(+ index/grid/API page): the new command's reference.Design decisions
options:is the home for sync tuning, not the entry root:rev/shallow/depthjoinpinunder one per-repository namespace rather than scattering VCS keys across the root. This keeps "how to clone" and "may vcspull edit this entry" co-located and the entry root limited torepo/remotes/worktrees.syncwarning) and rewritten by a dedicatedvcspull migratecommand, so existing configs keep working through a grace period.shallow: true(the common case, unchanged from v1.61.0); only a genuine window (depth > 1) recordsdepth: N.GitSync.obtain()already resolves "explicit depth wins, else shallow→depth 1, else full," so vcspull records and forwards rather than re-implementing precedence at sync time.Verification
--depthis wired into both importers:$ rg -n '"--depth"' src/vcspull/cli/add.py src/vcspull/cli/discover.pyThe reader and migrator share one canonical key list:
$ rg -n 'LEGACY_REPO_OPTION_KEYS' src/vcspullThe migrate subcommand is registered and dispatched:
$ rg -n 'migrate' src/vcspull/cli/__init__.pyEnd-to-end migrate (preview → write → idempotent):
Before / After
Config written by
vcspull add/discoverand read bysync:Test plan
uv run ruff format .— formatting cleanuv run ruff check . --fix --show-fixes— lint cleanuv run mypy .— types cleanuv run py.test --reruns 0— full suite greenjust build-docs— docs build; newcli-migrate/ config references resolvetest_detect_git_depth,test_resolve_clone_depth_explicit,test_resolve_clone_depth_autodetect— depth detection and hybrid precedencetest_extract_repos_lifts_options_sync_keys— reader surfacesoptions:and legacy forms,options:winstest_migrate_repo_entry,test_migrate_config,test_migrate_idempotent,test_migrate_cli_end_to_end— relocation, depth-wins, idempotency, CLItest_update_repo_git_depth—options.depthclones at--depth Non synctest_load_configs_warns_on_legacy_options— sync warns on the deprecated top-level formtest_discover_detects_numeric_depth,test_discover_detects_shallow_clone— auto-detection records the right keyadd/discoverfixtures assert theoptions:output shape with--depthcasesCloses #552