Java Reference
In-Depth Information
Viewing the differences between two versions of a file
Through the
History
view, you can view the differences between the version listed
and the source you're working on by selecting the version number and clicking
the
Compare with Local
button in the
History
window to launch the diff tool. A
diff tool
is an application that lets you visually inspect each line that was added,
removed, or modified in one file relative to another version of the file. This is
commonly known as viewing
a diff
.
IDEA
ships with an excellent diff viewer, but
you can configure your
General Settings
to use an external one if you like. Either
way, you can view the difference between one version and another from many dif-
ferent locations within the
IDEA
:
■
The History list
■
The
Commit Project
screen
■
The Project tool window's
CVS
| Compare with
context menu
■
The editor's
CVS
| Compare with
context menu
To examine the changes between two arbitrary versions of the file, bring up the
version history list, and then hold down the
Ctrl
key and select two different ver-
sions. The
Compare
button views the differences between the two selected ver-
sions. Note that you don't need to select sequential versions:
IDEA
can handle
viewing the differences between any two versions of the file. Otherwise, the
Com-
pare with Latest Repository Version
command, available from the
CVS
menu,
shows you the modifications you've made to the file, compared to the latest ver-
sion from the repository.
Using IDEA's diff viewer
When you request the differences between two versions,
IDEA
launches its diff
viewer. The diff viewer features two panes: The older of the two files is shown on
the left, and the newer on the right. The content of each file is shown in its
respective frame, separated by a margin, which shows the line numbers for each
file. You can adjust the size of the panes by left-clicking in the gutter area between
them and dragging left or right. Any differences between the two versions of the
files you're examining are highlighted with color-coded status indicators, as
shown in figure 8.17. The colored callouts show the type of change that was
made. Each change is mapped back to the appropriate line in the older file,
showing you exactly how the file was affected.