<?xml version="1.0" encoding="UTF-8"?>
<article id="Version_control">
  <title>Using WinMerge with other tools<indexterm>
      <primary>integration</primary>
    </indexterm></title>

  <para>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.</para>

  <section>
    <title>Using the command-line interface (CLI)</title>

    <para>The WinMerge command-line interface (CLI), described in <xref
    linkend="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.</para>

    <para>Here are just a few examples:</para>

    <itemizedlist>
      <listitem>
        <para>A batch file can launch WinMerge and enable users to specify
        parameters interactively:</para>

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

      <listitem>
        <para>The Subversion client allows you to call an external diff program
        and pass parameters, like this:</para>

        <literallayout>$ svn diff --diff-cmd "C:\Program Files\WinMerge\WinMergeU.exe" -x "-dl -dr" myfile </literallayout>
      </listitem>
    </itemizedlist>

    <tip>
      <para>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.</para>
    </tip>
  </section>

  <section id="VersionControl_vcs">
    <title>Using WinMerge with version control systems<indexterm>
        <primary>version control systems</primary>

        <secondary>integration with</secondary>
      </indexterm></title>

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

    <section>
      <title>Using WinMerge as a version control system's diff tool</title>

      <indexterm>
        <primary>TortoiseSVN integration</primary>
      </indexterm>

      <para>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 <link
      linkend="Installing_usinginstaller">WinMerge installation</link>.</para>

      <example>
        <title>Tortoise SVN integration</title>

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

        <orderedlist>
          <listitem>
            <para>In Windows Explorer, navigate to a Subversion working copy
            that you have checked out.</para>
          </listitem>

          <listitem>
            <para>Right-click a file that is under Subversion management
            (usually indicated by a distinct TortoiseSVN icon), and click
            <guimenu>TortoiseSVN</guimenu> in the context menu.</para>

            <itemizedlist>
              <listitem>
                <para>If the file has not been modified, the context menu
                contains the shortcut, <guimenuitem>Diff with previous
                version</guimenuitem>. This command compares the checked-out
                version of the file with the previous version that was checked
                in to the repository.</para>
              </listitem>

              <listitem>
                <para>If you have modified the file, the context menu contains
                the same <guimenuitem>Diff with previous version</guimenuitem>
                shortcut, plus the <guimenuitem>Diff</guimenuitem> 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.</para>
              </listitem>
            </itemizedlist>
          </listitem>

          <listitem>
            <para>Choose either the <guimenuitem>Diff with previous
            version</guimenuitem> or <guimenuitem>Diff</guimenuitem> shortcut.
            The WinMerge window opens, with the target file versions loaded In
            the File Compare window.</para>
          </listitem>
        </orderedlist>

        <para>The <menuchoice>
            <guimenu>TortoiseSVN</guimenu>

            <guimenuitem>Diff</guimenuitem>
          </menuchoice> 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:</para>

        <orderedlist>
          <listitem>
            <para>In Windows Explorer, hold <keycap>Ctrl</keycap>, select any
            two files, and right-click.</para>
          </listitem>

          <listitem>
            <para>Choose <menuchoice>
                <guimenu>TortoiseSVN</guimenu>

                <guimenuitem>Diff</guimenuitem>
              </menuchoice> in the context menu.</para>

            <para>The WinMerge window opens, with the selected files loaded In
            the File Compare window.</para>
          </listitem>
        </orderedlist>
      </example>

      <example>
        <title>Visual Studio Team Foundation Server integration</title>

        <para>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.</para>

        <orderedlist>
          <listitem>
            <para>In Visual Studio, navigate to the 
			  <menuchoice>
                <guimenu>Tools</guimenu>

                <guimenuitem>Options...</guimenuitem>
              </menuchoice> menu.</para>
          </listitem>
		  
          <listitem>
            <para>Under <menuchoice>
                <guimenu>Source Control</guimenu>
              </menuchoice>, find the<menuchoice>
                <guimenu> Visual Studio Team Foundation Server</guimenu>
              </menuchoice> options.</para>
          </listitem>
		  
          <listitem>
            <para>Click the <guimenuitem>Configure User Tools...</guimenuitem> button.</para>
          </listitem>

          <listitem>
            <para>Click the <guimenuitem>Add...</guimenuitem> button.</para>
          </listitem>
		  
		  <listitem>
            <mediaobject>
              <imageobject>
                <imagedata fileref="screenshots/tfs_configure.png" format="PNG" />
              </imageobject>
            </mediaobject>
			<para>Type in the following options in the Configure Tool.</para>
			<itemizedlist>
              <listitem>
                <para>Extension: .*</para>
              </listitem>

              <listitem>
                <para>Operation: Compare</para>
              </listitem>
			  
			  <listitem>
                <para>Command: {Path to WinMerge}\WinMergeU.exe</para>
              </listitem>
			  
			  <listitem>
                <para>Arguments: /e /u /dl %6 /dr %7 %1 %2</para>
              </listitem>
            </itemizedlist>
			<para> 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</para>
			<para> The arguments are described under <xref linkend="Command_line" />.</para>
          </listitem>
        </orderedlist>
		
		<para>Every time you tell TFS to compare two files, it will now use WinMerge.</para>
      </example>
    </section>
  </section>
</article>
