Command-Line Reference

Merge provides several command-line tools that enable you to launch Merge from a variety of applications. The AppleScript API enables even greater control over Merge.

Compare command-line utility

The primary (and recommended) way to use Merge from the command-line is to use the Compare command-line utility (compare). This utility program uses AppleScript to launch file comparisons within a new or existing instance of Merge.

Information Before using compare, ensure that the command-line utilities have been installed as described in the Installing the Merge command-line utilities section of the How to Install page.

Usage

compare [-? | -h] [-[no]wait] [-merge] [-testconflicts] [-readonly] [-aN]
    [-swap] [-max] [[-titleN:"<NthFileTitle>"]…] [-2 | -3]
    <firstFile> <secondFile> [<thirdFile>] [<mergedOutputFile>]

For two-way comparisons, two filename arguments should be specified. These are the files that will be displayed within the file comparison window. An optional third filename argument can also be specified. This third argument is used as the default save filename if you save changes to either of the files in the file comparison window (for example, by choosing Save or Save As… from the context menu that appears when a file panel is right-clicked).

For three-way comparisons, three filename arguments should be specified. It is important that the common ancestor or base file (if any) is displayed in the middle file panel. This can be specified with the -aN command-line option. As with two-way comparisons, a further optional argument can be specified to set the default filename name used if a file is saved.

When merging three files, it is easiest to merge changes from the left and right files into the middle file. This is why the common ancestor file should be displayed in the middle file panel. Once the changes have been merged into the common ancestor file, right click the middle file panel and choose Save or Save As… to save the merged file.

The command-line arguments are described below.

  • -? or -h Displays usage summary.
  • -wait Wait for user to close the compared files in Merge before exiting.
  • -nowait Prevents compare from waiting for a comparison to be closed.
  • -merge Performs an automatic three-way merge to the common ancestor file after comparing three files.
  • -testconflicts When combined with -merge, checks whether an automatic three-way merge would cause merging conflicts. The program’s return code is the number of conflicts encountered.
  • -readonly Prevents the compared files from being edited.
  • -aN (N is 1, 2 or 3) The Nth filename argument specifies a common ancestor of the other two files. The common ancestor is shown in the middle file panel. Only valid for three-way comparisons.
  • -swap Swaps the files displayed in the left and right panels.
  • -max Maximizes the Merge application window.
  • -titleN:"<NthFileTitle>" (N is 1, 2 or 3) Sets a friendly title for the file panel that displays the Nth file specified on the command-line. Single or double quotes must be used to surround the title. This feature enables a VC or SCM system to provide meaningful names for file panel titles. For example, "Djn’s Revision v1.1.1", "Common Ancestor" and "Jrs’s Revision v1.1.2" could be used as the three file panel titles.
  • -2 Performs a two-way comparison (default) of the files <firstFile> and <secondFile>. If present, <mergedOutputFile> is used as the default save filename for the results of any merge.
  • -3 Performs a three-way comparison (only available in the Professional Edition of Merge) of the files <firstFile>, <secondFile> and <thirdFile>. If present, <mergedOutputFile> is used as the default save filename for the results of any merge.

Examples

1.

compare file1.txt file2.txt

Opens a file comparison window comparing the two specified files.

2.

compare -wait file1.txt file2.txt

Opens a file comparison window comparing the two specified files. Compare will not exit until the user closes the file comparison window.

3.

compare -wait file1.txt file2.txt /tmp/merged.txt

Opens a file comparison window comparing the first two specified files. If the user attempts to save changes to either of the two files, /tmp/merged.txt will be used as the default save file name. Compare will not exit until the user closes the file comparison window.

4.

compare -wait -a1 -3 /tmp/file1.txt /tmp/file2.txt /tmp/file3.txt

Opens a file comparison window comparing the three specified files. Compare will not exit until the user closes the file comparison window. The first file specified is treated as the common ancestor of the other two and is therefore displayed in the middle file panel.

5.

compare -wait -a3 -3 -title1:"Djn’s Revision" -title2:"Jrs’s Revision" -title3:"Common Ancestor" /tmp/file1.txt /tmp/file2.txt /tmp/file3.txt /tmp/merged.txt

Opens a file comparison window comparing the first three specified files. If the user attempts to save changes to either of the three files, /tmp/merged.txt will be used as the default save file name. Compare will not exit until the user closes the file comparison window. The third file specified is treated as the common ancestor of the other two and is therefore displayed in the middle file panel. The file panels are given meaningful names.

araxisp4diff

This utility can be used to enable the Perforce command-line utility (p4) and Perforce Visual Client (p4v) to use Araxis Merge to compare files. It can also be used as a simpler replacement for the compare utility.

Usage

araxisp4diff [-? | -h] <firstFile> <secondFile>

To use araxisp4diff with the Perforce command-line tools, set the P4DIFF environment variable to reference araxisp4diff. For example, add the following line to your ~/.profile file:

export P4DIFF='/Applications/Araxis Merge/Utilities/araxisp4diff'

Information Since Araxis Merge is capable of comparing binary and image files, you should generally include the -t option when using the p4 diff command. For example:

p4 diff -t

araxisp4winmrg

This utility can be used to enable the Perforce command-line utility (p4) and UI (p4v) to use Araxis Merge to merge files.

Usage

araxisp4winmrg [-? | -h] <ancestorFile> <theirFile> <yourFile> <saveFile>

To use araxisp4winmrg with the Perforce command-line tools, set the P4MERGE environment variable to reference araxisp4winmrg. For example, add the following line to your ~/.profile file:

export P4MERGE='/Applications/Araxis Merge/Utilities/araxisp4winmrg'

araxissvndiff

This utility can be used to enable the Subversion command-line utility (svn) to use Araxis Merge to compare files.

Usage

araxissvndiff [-? | -h] <firstTitle> <secondTitle> <firstFile> <secondFile>

To use araxissvndiff with the Subversion command-line tools, edit your ~/.subversion/config so that the diff-cmd property in the [helpers] section references araxissvndiff. For example:

diff-cmd = /Applications/Araxis\ Merge/Utilities/araxissvndiff

Information This line is commented-out in the default configuration file, so you should remove the # character and space at the start if present.

araxissvndiff3

This utility can be used to enable the Subversion command-line utility (svn) to use Araxis Merge to merge files.

Usage

araxissvndiff3 [-? | -h] <mineTitle> <olderTitle> <yoursTitle> <mineFile> <olderFile> <yoursFile>

To use araxissvndiff3 with the Subversion command-line tools, edit your ~/.subversion/config so that the diff3-cmd property in the [helpers] section references araxissvndiff3. For example:

diff3-cmd = /Applications/Araxis\ Merge/Utilities/araxissvndiff3

Information This line is commented-out in the default configuration file, so you should remove the # character and space at the start if present.