Skip to content

feat: add Perforce (P4) pending changelist diff support#472

Merged
backnotprop merged 2 commits intobacknotprop:mainfrom
rtsummit:feat/p4-support
Apr 2, 2026
Merged

feat: add Perforce (P4) pending changelist diff support#472
backnotprop merged 2 commits intobacknotprop:mainfrom
rtsummit:feat/p4-support

Conversation

@rtsummit
Copy link
Copy Markdown
Contributor

@rtsummit rtsummit commented Apr 2, 2026

Summary

  • Add Perforce workspace detection and pending changelist diff support for code review
  • Introduce VcsProvider interface with Git and P4 implementations, enabling extensible VCS support via a provider registry pattern
  • Auto-detect Git vs P4 workspace and route diff/file-content/staging operations to the appropriate backend

Details

  • New files: packages/server/p4.ts (P4 runtime), packages/server/vcs.ts (VCS dispatch layer)
  • P4 features: workspace detection with TTL cache, default + numbered changelist diffs, binary file exclusion, p4 add (new file) support, batch p4 where resolution
  • DiffType additions: p4-default, p4-changelist:<N>
  • Staging: disabled for P4 (no staging concept); Git staging unchanged
  • Breaking changes: None — existing Git behavior is preserved

Test plan

  • Verify Git-based code review still works as before
  • Test in a Perforce workspace: default changelist appears in diff dropdown
  • Test numbered changelists with files appear in dropdown
  • Verify binary files are excluded from P4 diffs
  • Verify staging UI is hidden/disabled in P4 mode

🤖 Generated with Claude Code

ABTN-rtsummit and others added 2 commits April 2, 2026 21:37
Introduce P4 support alongside existing Git backend via a VCS dispatch
layer (vcs.ts). Detects Git vs Perforce workspace automatically and
routes diff/file-content operations to the appropriate backend.

- Add p4-default and p4-changelist:<N> DiffType variants
- Add P4 runtime (p4.ts): workspace detection with TTL cache, changelist
  context, unified diff conversion, binary file exclusion, batch p4 where
- Add VCS dispatch layer (vcs.ts): auto-detect Git/P4, unified API
- Update review server and CLI entry point to use VCS dispatch
- Filter empty changelists from dropdown, disable staging for P4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded Git/P4 dispatch with a provider-based architecture.
Each VCS implements VcsProvider interface and registers in a providers
array — adding a new VCS only requires implementing the interface.

- Define VcsProvider with detect, ownsDiffType, getContext, runDiff,
  getFileContents, and optional stageFile/unstageFile/resolveCwd
- Create gitProvider and p4Provider as concrete implementations
- Replace isP4DiffType/gitAddFile/gitResetFile in review.ts with
  provider-based canStageFiles/stageFile/unstageFile/resolveVcsCwd
- Remove VCS-specific branching from review server endpoints

Note: GitContext interface is not renamed to VcsContext in this commit.
The rename touches too many files across the codebase (Pi extension,
OpenCode plugin, shared types, tests) and should be handled as a
separate pull request to keep the diff reviewable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@backnotprop
Copy link
Copy Markdown
Owner

Nice work

@backnotprop backnotprop merged commit e642e25 into backnotprop:main Apr 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants