Comparing a Method Source

Use the Compare command from the Methods menu Delta submenu in the Class Browser or Primitive Types Browser to compare the original and updated sources of the selected checked out method.

Method sources can be compared only when a delta is set and the method is checked out.

You can change your default source comparison options, if required, by using the Compare Sources group box controls of the Source Management sheet from the Options menu Preferences command. For example, you can select the comparison of changes only or that white space is to be compared.

To compare the original and updated sources of a checked out method

  1. In the Methods List of the Class Browser or Primitive Types Browser, select the checked out method whose sources you want to compare.

  2. Select the Compare command from the Methods menu Delta submenu.

  3. The Compare Sources window, shown in the following image, is then displayed.

The upper part of the Compare Sources window (for the default Visual option in the Preferences dialog Source Management sheet) contains two panes, displaying the original source code of the method and the updated source code of the checked out method. As these panes are read-only, you cannot change the source code in either of them.

By default, the pane at the left of the window displays the source that is currently checked out and the pane at the right of the window displays the method source in the delta that is currently set. If you want to view the original source (that is, before the method was checked out to a delta), select the Original value in a combo box above the left or the right pane. Use these to compare the checked out method with the current source and the original source.

The merge editor pane in the lower area of the Compare Sources window enables you to copy source code from the original or updated source code pane, update it to meet your requirements, and then save it to your current delta.

When you have multiple deltas, the original source may not be the same as the current source, because a method can be changed in more than once.

If a method has been checked out to more than one delta, the combo boxes enable you to select the delta in which you want to compare the method source.

The comparisons that are displayed in the Compare Sources window are listed in the following table.

Color Description
Blue Addition in method line
Green Change in method line
Red Deletion in method line

The popup menu accessed from either of the source code panes provides the Copy to Merge Window command, which copies all of the code in that pane to the merge editor pane. You can then change the copied source and then save it by clicking the Save button. The saved source is saved to your current delta.

By default, changes to white space (for example, a space or a tab) are ignored. If the Ignore White Space option is checked in the Source Management sheet of the User Preferences dialog, it may appear that no changes have been made even though the source has been modified; for example, indentation may have been changed.

You can copy code to the clipboard from either the current or the latest source windows displayed in the Compare Sources window, by using the Copy command in the Edit menu (or press Ctrl+C) or the Copy toolbar button so that you can then paste the code into a text editor or into the editor pane of another method, for example. The source code window that is copied is the one that has focus.

Alternatively, you can click the Next button to highlight the next line of your source code that has been updated and the original source, if applicable, or the Previous button to highlight the previous line of source code that has been updated and the original source.