Skip to content

Add option to use Visual Studio built-in diff for Diff Against Have Revision#44

Open
rtsummit wants to merge 2 commits into
SimpsonGSD:masterfrom
rtsummit:feat/vs-builtin-diff
Open

Add option to use Visual Studio built-in diff for Diff Against Have Revision#44
rtsummit wants to merge 2 commits into
SimpsonGSD:masterfrom
rtsummit:feat/vs-builtin-diff

Conversation

@rtsummit
Copy link
Copy Markdown

Summary

  • Adds a new Use Visual Studio Diff option (Tools > Options > P4EditVS, default on) that opens "Diff Against Have Revision" inside Visual Studio using IVsDifferenceService instead of launching p4vc diffhave in P4V.
  • The have revision is fetched via p4 print -q -o <temp> into %TEMP%\P4EditVS_<guid>_have<ext>, preserving the file extension so VS picks the right content type.
  • Existing p4vc diffhave behaviour is preserved — flip the option off to restore it.

Why

Keeps diff inside the IDE so the workflow doesn't break to switch focus to P4V. The original p4vc diffhave path is unchanged behind the toggle for users who prefer it.

Implementation notes

  • VSDIFFOPT_LeftFileIsTemporary alone does not reliably remove the temp file, and per-frame close hooks race with the diff editor still holding the file handle. Temp paths are instead tracked in a static list and cleaned up on P4EditVS.Dispose.
  • All existing Runner / OutputWindow / status bar conventions are reused — p4 print failures show up in the P4EditVS output pane and as a status bar failure, identical to other commands.
  • No new SDK dependencies (IVsDifferenceService / SVsDifferenceService are present in both the VS2019 and VS2022 SDKs used by this project).

Test plan

  • VS2022 flavor builds clean (Release / Any CPU) — no warnings or errors.
  • Option "Use Visual Studio Diff" appears in Tools > Options > P4EditVS > Settings, defaults to on.
  • With the option on, Diff Against Have Revision opens VS's built-in diff window with <filename>#have on the left and the workspace file on the right.
  • After closing Visual Studio, %TEMP%\P4EditVS_* files are removed.
  • With the option off, the existing p4vc diffhave codepath runs unchanged (note: p4vc diffhave behaviour itself is outside the scope of this PR).
  • p4 print failure (e.g. file with no have revision) surfaces in the P4EditVS output pane and as a status bar failure — needs verification.
  • VS2019 flavor — relies on CI build; not built locally for this PR.

🤖 Generated with Claude Code

ABTN-rtsummit and others added 2 commits May 18, 2026 16:28
Adds a "Use Visual Studio Diff" option (default on) that runs
`p4 print` to fetch the have revision into a temp file, then opens
the comparison in VS via IVsDifferenceService.OpenComparisonWindow2
instead of launching p4vc diffhave in P4V.

Temp files are tracked in a static list and deleted on package
Dispose, so they don't accumulate across the session.

Users who prefer the existing P4VC diff window can turn the option
off in Tools > Options > P4EditVS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The hosted windows-2019 image has been deprecated, causing the
pipeline to fail with "No image label found to route agent pool"
before the build even starts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants