<type>documentation</type>
<domain>diff</domain>
<id>diff</id>
<title>Difference and Merge</title>
<date>$Date: 2010-05-14 11:53:19 -0400 (Fri, 14 May 2010) $</date>
<version>$Revision: 22093 $</version>
<product>pro+</product>

.. _diff:

Wing Pro provides single and multi-file difference and merge capabilities that can be used to
compare files or directories on disk and to manage differences to an `Integrated Version Control
<ref:versioncontrol/index>`__ system.

To initiate a session, click on the ``Diff/Merge`` toolbar item or use the ``Difference and Merge``
sub-menu of the ``Source`` menu or ``Compare to Repository`` in the editor's right-click conrext
menu. You will be prompted for any needed file or directory names in a dialog or, for some `keyboard
personalities <ref:custom/keyboard-personalities>`__, in the status area at the bottom of the IDE
window. Additional sessions can be started concurrently but only one session is current at a given
time. The same menus can be used to switch among active ``Diff/Merge`` sessions, when there are two
or more.

Once a session is started, the selected files will be displayed side by side, one annotated with
``A:`` and the other annotated with ``B:``. Use the floating buttons shown between the editors or
the newly revealed toolbar items to move to the next or previous difference pair, to merge
differences from one file into the other, to undo merges you have already made in the session, or to
terminate the session. Navigation and merging is also possible with the key bindings listed in the
``Difference and Merge`` sub-menu of the ``Source`` menu.

While a diff/merge session is active, a summary listing all changes is available from the
``Diff/Merge`` icon displayed at the top right of editors in the active session. This includes line
number, change summary, and Python scope name when applicable. Selecting a change from this menu
will jump to it.

Session Types
-------------

The following types of ``Diff/Merge`` sessions are available:

**Compare Files** compares two selected files on disk.

**Compare Directories** compares two selected directories on disk. The `Diff/Merge 
<script:show_panel#panel_type="diff">`__ tool, which will be shown while the session is active,
will display a list of files and estimated degree of difference in each file pair.
Clicking on the list will display the first difference in the selected file pair. The
selection on the list will also update as you move through the difference list.

**Compare Visible Files** compares the two visible editors. This is only available when two
or more editor splits are shown and two different files are open in them. If three or more
splits are shown, the files in the last two splits are compared.
  
**Compare Buffer with Disk** compares the current unsaved editor and its disk file. This
is only available when the current file has unsaved edits.
  
**Compare Recent** provides a sub-menu for quick access to recently performed comparisons.
  
**Compare to Repository** can be used to compare the working copy of a file with the
corresponding repository revision. This is only available if the file is checked into one
of the `version control systems <ref:versioncontrol/index>`__ that Wing Pro supports.
  
The diff/merge capability can also be used to review changes made by the ``AI Coder``
tool, as described in `AI Coder Tool <ref:ai/coder>`__.

Options
-------

The ``Difference and Merge`` sub-menu of the ``Source`` menu contains two items that
control the behavior of ``Diff/Merge`` sessions:

**Lock Scrolling** keeps the scrolling position of the two files in the ``Diff/Merge``
session synchronized.
  
**Ignore Whitespace** ignores changes that consist solely of white space (space, tab,
line feed, or carriage return characters).
  
These are also available in preferences, along with the following other options:

The `Editor > Diff/Merge > Empty Session Warning
<script:show_preferences_gui#prefname="diff.empty-session-warning">`__ preference 
chooses whether a warning should be shown if some changes were ignored because
of the ``Ignore Whitespace`` setting.

The `Editor > Diff/Merge > Orientation
<script:show_preferences_gui#prefname="diff.orientation">`__ preference selects between
side by side or top/bottom orientation of the two files shown during a ``Diff/Merge``
session.

The `Editor > Diff/Merge > Diff Color <script:show_preferences_gui#prefname="edit.qt-diff-color">`__
and `Editor > Diff/Merge > Merged Diff Color <script:show_preferences_gui#prefname="edit.qt-merged-diff-color">`__ 
preference selects the color used in the ``Diff/Merge`` highlights on the editor.



