Using WinMerge with other tools

Comparing and merging files are often subtasks in a larger change management process. For that reason, WinMerge is often used not just by itself, but also in conjunction with other tools. In addition, diff and merge utilities provide different features, so it's sometimes handy to combine different tools. This topic describes the primary methods for using WinMerge with other tools.

1. Using the command-line interface (CLI)

The WinMerge command-line interface (CLI), described in Command line, enables you to run WinMerge from a Command Prompt window, from scripts, or from another tool or program. Basically, any program that allows you to call an external executable with at least one path, can be used to launch a WinMerge operation.

Here are just a few examples:

  • A batch file can launch WinMerge and enable users to specify parameters interactively:

    start "WinMerge" /B "C:\Program Files\WinMerge\WinMergeU.exe" /e /s /u /dl %3 /dr %5 %6 %7

  • The Subversion client allows you to call an external diff program and pass parameters, like this:

    $ svn diff --diff-cmd "C:\Program Files\WinMerge\WinMergeU.exe" -x "-dl -dr" myfile 

[Tip] Tip

Similarly, many GUI tools (like version control clients and IDEs) that include built-in diff tools enable you to configure WinMerge as their default diff tool, instead. The next section describes how to use WinMerge this way with TortoiseSVN and Visual Studio Team Foundation Server. For other tools, like Eclipse and Perforce, check their documentation or search the Internet for details and examples.

2. Using WinMerge with version control systems

You can configure WinMerge to interact with a few supported version control systems (VCS). This section describes the VCS integration and provides some examples.

2.1. Using WinMerge as a version control system's diff tool

When you compare files in TortoiseCVS, TortoiseSVN, or TortoiseGIT, you can have the VCS launch WinMerge instead of its native diff utility. You can configure some of these integrations during WinMerge installation.

Example 1. Tortoise SVN integration

Here is a sample diff operation in TortoiseSVN that uses the WinMerge integration. The integrations with TortoiseCVS and TortoiseGIT are similar.

  1. In Windows Explorer, navigate to a Subversion working copy that you have checked out.

  2. Right-click a file that is under Subversion management (usually indicated by a distinct TortoiseSVN icon), and click TortoiseSVN in the context menu.

    • If the file has not been modified, the context menu contains the shortcut, Diff with previous version. This command compares the checked-out version of the file with the previous version that was checked in to the repository.

    • If you have modified the file, the context menu contains the same Diff with previous version shortcut, plus the Diff shortcut. This command compares your revision to the current version (the one you checked out). It is useful for reviewing the changes you have made.

  3. Choose either the Diff with previous version or Diff shortcut. The WinMerge window opens, with the target file versions loaded In the File Compare window.

The TortoiseSVNDiff shortcut is available for comparing any two files in your file system, not just files that are managed by Subversion. To illustrate how the WinMerge integration works in this case:

  1. In Windows Explorer, hold Ctrl, select any two files, and right-click.

  2. Choose TortoiseSVNDiff in the context menu.

    The WinMerge window opens, with the selected files loaded In the File Compare window.

Example 2. Visual Studio Team Foundation Server integration

You can manually set up WinMerge as the default tool to use for in Visual Studio to show differences in Team Foundation Server (TFS) Other version control systems can be set up in very similar ways.

  1. In Visual Studio, navigate to the ToolsOptions... menu.

  2. Under Source Control, find the Visual Studio Team Foundation Server options.

  3. Click the Configure User Tools... button.

  4. Click the Add... button.

  5. Type in the following options in the Configure Tool.

    • Extension: .*

    • Operation: Compare

    • Command: {Path to WinMerge}\WinMergeU.exe

    • Arguments: /e /u /dl %6 /dr %7 %1 %2

    Where {Path to WinMerge} is the path were WinMerge is installed. In the above screenshot it is installed to the default installation path C:\Program Files (x86)\WinMerge\WinMergeU.exe

    The arguments are described under Command line.

Every time you tell TFS to compare two files, it will now use WinMerge.