Skip to content

Refactor compare engines to use DiffContext#3197

Merged
sdottaka merged 4 commits into
masterfrom
refactor/compare-engines
Feb 12, 2026
Merged

Refactor compare engines to use DiffContext#3197
sdottaka merged 4 commits into
masterfrom
refactor/compare-engines

Conversation

@sdottaka

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the compare engine classes (BinaryCompare, TimeSizeCompare, ExistenceCompare, and ImageCompare) to receive configuration through a CDiffContext reference passed to their constructors, rather than through individual method parameters. This simplifies the API by consolidating context information (comparison method, number of files, options) into a single context object.

Changes:

  • Modified all compare engine constructors to accept a CDiffContext reference and store it as a member variable
  • Updated CompareFiles methods to use context information from the stored CDiffContext instead of method parameters
  • Updated production code (FolderCmp.cpp, MergeFrameCommon.cpp) to pass CDiffContext when constructing compare engines
  • Updated test files to create CDiffContext objects with appropriate PathContext for 2-way and 3-way comparisons

Reviewed changes

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

Show a summary per file
File Description
Src/CompareEngines/BinaryCompare.h Changed constructor to accept CDiffContext reference; removed SetAbortable method; CompareFiles no longer takes PathContext parameter
Src/CompareEngines/BinaryCompare.cpp Constructor simplified to inline initialization; CompareFiles now calls GetComparePaths and GetAbortable from stored context; changed IAbortable parameter to const
Src/CompareEngines/TimeSizeCompare.h Added member variables for nfiles, compMethod, ignoreSmallDiff; removed SetAdditionalOptions method; CompareFiles signature simplified
Src/CompareEngines/TimeSizeCompare.cpp Constructor initializes members from CDiffContext; removed SetAdditionalOptions implementation; CompareFiles uses member variables instead of parameters; changed auto to constexpr auto
Src/CompareEngines/ExistenceCompare.h Added m_nfiles member; changed constructor and CompareFiles signatures
Src/CompareEngines/ExistenceCompare.cpp Constructor initializes m_nfiles from context; CompareFiles uses m_nfiles instead of parameter
Src/CompareEngines/ImageCompare.h Changed constructor to accept CDiffContext; removed SetColorDistanceThreshold method; CompareFiles signature simplified; added m_ctxt member
Src/CompareEngines/ImageCompare.cpp Constructor initializes color distance threshold from context; CompareFiles calls GetComparePaths from stored context
Src/FolderCmp.cpp Updated to pass *m_pCtxt when constructing compare engines; removed calls to SetAdditionalOptions, SetAbortable, SetColorDistanceThreshold; removed PathContext creation before CompareFiles calls
Src/MergeFrameCommon.cpp Creates CDiffContext and passes it to BinaryCompare constructor; updated file path setup for DIFFITEM
Testing/GoogleTest/BinaryCompare/BinaryCompare_test.cpp Tests now create CDiffContext objects for 2-way and 3-way comparisons; updated to set file info via SetFile method
Testing/GoogleTest/ExistenceCompare/ExistenceCompare_test.cpp Tests now create CDiffContext objects for 2-way and 3-way comparisons
Testing/GoogleTest/TimeSizeCompare/TimeSizeCompare_test.cpp Tests now create CDiffContext objects for 2-way and 3-way comparisons; removed SetAdditionalOptions calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Testing/GoogleTest/TimeSizeCompare/TimeSizeCompare_test.cpp Outdated
Comment thread Testing/GoogleTest/TimeSizeCompare/TimeSizeCompare_test.cpp Outdated
Comment thread Testing/GoogleTest/TimeSizeCompare/TimeSizeCompare_test.cpp Outdated
Comment thread Testing/GoogleTest/TimeSizeCompare/TimeSizeCompare_test.cpp Outdated
@sdottaka sdottaka requested a review from Copilot February 11, 2026 23:52
@sdottaka sdottaka marked this pull request as ready for review February 11, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 16 out of 16 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

Src/MergeFrameCommon.cpp:86

  • The error message is misleading when the comparison fails. It says "Selected files are identical (with current settings)" when in fact a comparison error occurred. The message should indicate that the comparison could not be completed. Additionally, this code does not handle the CMPABORT case (when the user cancels the operation) separately from errors.
		if (di.diffcode.isResultError())
			return _("Selected files are identical (with current settings).\r\nBut binary comparison failed.");
		return di.diffcode.isResultSame()
			? _("Selected files are identical (binary match).")
			: _("Selected files are identical (with current settings).\r\nBut differ at the binary level.");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Src/CompareEngines/ImageCompare.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sdottaka sdottaka merged commit 19d179c into master Feb 12, 2026
4 checks passed
@sdottaka sdottaka deleted the refactor/compare-engines branch February 12, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants