Skip to content

Add new baseline-diff command#1980

Open
autoantwort wants to merge 1 commit intomicrosoft:mainfrom
autoantwort:feature/baseline-diff
Open

Add new baseline-diff command#1980
autoantwort wants to merge 1 commit intomicrosoft:mainfrom
autoantwort:feature/baseline-diff

Conversation

@autoantwort
Copy link
Copy Markdown
Contributor

If we use x-update-baseline we wanted to know which packages gets updated for our manifest file.

Copilot AI review requested due to automatic review settings April 8, 2026 09:40
@autoantwort autoantwort force-pushed the feature/baseline-diff branch 2 times, most recently from 04a5e7a to 9d4ae6d Compare April 8, 2026 09:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new experimental x-baseline-diff command to help users understand which manifest dependencies would change when moving between two baselines (commit refs), integrating it into the vcpkg command dispatcher and localization system.

Changes:

  • Adds x-baseline-diff command implementation and registers it in command dispatch.
  • Extends configuration with a helper intended to detect whether the default registry is the built-in registry.
  • Adds new localized strings for command synopsis/output headings and “no change” output.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/vcpkg/configuration.cpp Adds a helper intended to detect built-in default registry kind (currently incorrect).
include/vcpkg/configuration.h Exposes the new configuration helper in the public header.
src/vcpkg/commands.cpp Wires the new command into the command table (currently has a syntax error in the include).
src/vcpkg/commands.baseline-diff.cpp Implements the baseline comparison by generating two install plans and diffing versions.
include/vcpkg/commands.baseline-diff.h Declares the new command entrypoint/metadata.
locales/messages.json Adds user-facing strings for the command and output labels (some grammar issues).
include/vcpkg/base/message-data.inc.h Declares new messages for localization enforcement (some grammar issues).

Comment thread src/vcpkg/configuration.cpp Outdated
Comment thread include/vcpkg/configuration.h Outdated
Comment thread src/vcpkg/commands.baseline-diff.cpp Outdated
Comment thread src/vcpkg/commands.baseline-diff.cpp
Comment thread src/vcpkg/commands.baseline-diff.cpp
Comment thread include/vcpkg/commands.baseline-diff.h
Comment thread locales/messages.json Outdated
Comment thread locales/messages.json Outdated
Comment thread include/vcpkg/base/message-data.inc.h Outdated
Comment thread include/vcpkg/base/message-data.inc.h Outdated
@autoantwort autoantwort force-pushed the feature/baseline-diff branch from 9d4ae6d to a9849db Compare April 8, 2026 09:54
If we use x-update-baseline we wanted to know which packages gets updated for our manifest file.
Copilot AI review requested due to automatic review settings April 8, 2026 10:14
@autoantwort autoantwort force-pushed the feature/baseline-diff branch from a9849db to 4a51845 Compare April 8, 2026 10:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread src/vcpkg/commands.baseline-diff.cpp
Comment thread src/vcpkg/commands.baseline-diff.cpp
Comment thread src/vcpkg/commands.baseline-diff.cpp
Comment thread src/vcpkg/commands.baseline-diff.cpp
return false;
}

void check_for_valid_sha(StringView sha)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use check_commit_exists (from git.h) instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we can't do that in the general case because this kinda just blindly overwrites the baseline with a SHA and we don't necessarily have a git repo present for that.

However that makes this kinda broken because filesystem registries' baselines are not SHAs. We should only be checking that the input is a SHA when we know that registry has that constraint.

Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the general idea of such a command makes sense.

Most of what is here is nitpicks but the one about 'why manifest only' and 'what about non-git registries' are kinda foundational.

Should we have output like this printed by x-update-baseline instead of/in addition to what you've done here?

This needs at least one end to end test.

Thanks for the new command submission!

Comment on lines +41 to +46
bool print_lines(LocalizedString&& header, std::vector<std::string>&& lines)
{
if (!lines.empty())
{
Util::sort_unique_erase(lines);
msg::println(header.append_raw(':'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool print_lines(LocalizedString&& header, std::vector<std::string>&& lines)
{
if (!lines.empty())
{
Util::sort_unique_erase(lines);
msg::println(header.append_raw(':'));
bool print_lines(const msg::MessageT<>& header, std::vector<std::string>&& lines)
{
if (lines.empty())
{
return false;
}
Util::sort_unique_erase(lines);
msg::print(msg::format(header).append_raw(":\n"));

That is: early return on the false case, and pass msg::MessageT<> so we don't bother formatting at all in the no lines case.

I could have swore we already had a utility function doing something like this floating around but I'm not finding it...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm remembering format_plan_block in dependencies.cpp which isn't directly applicable here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied this in autoantwort#2

Comment on lines +94 to +95
check_for_valid_sha(options.command_arguments.at(0));
check_for_valid_sha(options.command_arguments.at(1));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check_for_valid_sha(options.command_arguments.at(0));
check_for_valid_sha(options.command_arguments.at(1));
check_for_valid_sha(options.command_arguments[0]);
check_for_valid_sha(options.command_arguments[1]);

{
if (auto default_reg = configuration.config.default_reg.get())
{
default_reg->baseline = options.command_arguments.at(i);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default_reg->baseline = options.command_arguments.at(i);
default_reg->baseline = options.command_arguments[i];

auto dependencies = get_manifest_dependencies(*manifest_scf, features);

ActionPlan plan[2];
for (int i = 0; i < 2; ++i)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0; i < 2; ++i)
for (size_t i = 0; i < 2; ++i)

to avoid any sugned/unsigned mismatch warnings from vector.

extended_overlay_port_directories,
manifest->path,
std::make_unique<SourceControlFile>(manifest_scf->clone()));
PackagesDirAssigner packages_dir_assigner{paths.packages()};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:sigh: We really need to have a "prepare for build" step and separate types for "I have a packages dir" and friends.

No change requested.

msgCmdBaselineDiffSynopsis,
{"vcpkg x-baseline-diff <old_commit_sha> <newer_commit_sha>",
"vcpkg x-baseline-diff $(git rev-parse 2026.02.27) $(git rev-parse 2026.03.18)"},
Undocumented,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a docs page for this.

Comment on lines +174 to +175
any_changes |= print_lines(msg::format(msgDirectDependencies), std::move(user_requested));
any_changes |= print_lines(msg::format(msgTransitiveDependencies), std::move(transitive));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
any_changes |= print_lines(msg::format(msgDirectDependencies), std::move(user_requested));
any_changes |= print_lines(msg::format(msgTransitiveDependencies), std::move(transitive));
any_changes |= print_lines(msgDirectDependencies, std::move(user_requested));
any_changes |= print_lines(msgTransitiveDependencies, std::move(transitive));

(to go with the change to print_lines above)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied this in autoantwort#2

{
RegistryConfig synthesized_registry;
synthesized_registry.kind = JsonIdBuiltin.to_string();
synthesized_registry.baseline = options.command_arguments.at(i);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
synthesized_registry.baseline = options.command_arguments.at(i);
synthesized_registry.baseline = options.command_arguments[i];

Triplet host_triplet)
{
const auto* manifest = paths.get_manifest();
if (manifest == nullptr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with this design: Because the user is explicitly passing in multiple baseline SHAs, it seems to really be more of a classic mode command as other registries aren't accounted for.

It seems like what you actually wanted is effectively this same diff but before/after what x-update-baseline does?

If this stays manifest only, it seems like one of the SHAs should be the one already in the manifest?

return false;
}

void check_for_valid_sha(StringView sha)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we can't do that in the general case because this kinda just blindly overwrites the baseline with a SHA and we don't necessarily have a git repo present for that.

However that makes this kinda broken because filesystem registries' baselines are not SHAs. We should only be checking that the input is a SHA when we know that registry has that constraint.

Copy link
Copy Markdown
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(paraphrased by @BillyONeal )
@vicroms: Anything that makes baselines more helpful and less obscure is a good thing
@AugP: This concept sounds like a good idea and I have no objections to it

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