Using twmerge |
28 |
![]() |
Starting twmerge from the command line enables you to:
Understanding Merging
Merging loads and displays two text files for side-by-side comparison, each in a read-only text pane. Any differences between the two files are marked, and a merged version of the two files which you can edit to produce a final merged version.
![]() | Type twmerge. |
To merge two files named file_1 and file_2, type:
demo% twmerge file_1 file_2 & |
The first file, file_1, opens in the left text pane; file_2 opens in the right pane.
Loading Three Files at Startup
To merge two files and compare them to a common ancestor, change to the directory in which the files are stored and type:
demo% twmerge -a ancestor_file file_1 file_2 & |
The ancestor file is not shown, but differences between the ancestor file and the two descendants are marked, with the output file being based on the ancestor file.
Loading Files from a List File
You can sequentially load files from a list of file names.
file_1 file_2 file_3 |
demo% twmerge -a /src -1 sourcelist /usr_1/usr_2/new_src & |
This command loads /usr_1/file_1 into the left text pane, /usr_2/file_1 into the right text pane, and sets the common ancestor as /src/file_1.
Working with Differences
Merging operates on differences between files. When Merging discovers a line that differs between the two files to be merged (or between either of the two files and an ancestor), it marks the lines in the two files with glyphs corresponding to how the lines differ. Together, these marked lines are called a difference. As you move through the files from one difference to the next, the lines that differ and their glyphs are highlighted. Current, Next, and Previous Difference
The highlighted difference is called the current difference. The differences immediately before and immediately after are called the previous difference and the next difference. Resolved and Remaining Difference
A difference is resolved if the changes to a line are accepted. A remaining difference is one that has not yet been resolved. Moving Between Differences
You can move between differences using the buttons above the two panes, or the Navigate menu. Use the Previous and Next buttons to scroll through the differences without accepting them. Resolving Differences
To resolve a difference, you accept the change in either the left or right pane.
![]() | Click the Accept button, or Click the Accept & Next button to accept the difference and move to the next difference. |
Glyph type |
Designates |
Plus sign |
New line |
Minus sign |
Deleted line |
Vertical bar |
Change in line |
No glyph |
No changes in line |
Comparing Three Input Files
When an common ancestor file is designates, glyphs next to the lines in each file indicate when they differ from the corresponding lines in the ancestor:
You can disable Auto Merge by choosing Options
If you do not specify an ancestor file, Merging has no reference with which to compare a difference between the two input files. Consequently, Merging cannot determine which line in a difference is likely to represent the desired change. The result of an auto merge with no ancestor is the same as disabling automatic merging: Merging constructs a merged file using only lines that are identical in both input files and relies on you to resolve differences.
To change the name of the output file while saving, choose Save As and fill in the new file and directory names in the resulting pop-up window, as shown in the following figure.
twmerge [-b] [-r] [-a ancestor] [-f1 name1] [-f2 name2] |
-b
-r
-a
ancestor
-f1
name1
-f2
name2
-l
listfile
rightfile--The name of the file to be loaded into the right pane for comparison. When used with the -l listfile option, rightfile is a directory of files, which you can load in succession.
outfile--Specifies the name of the merged output file. If you do not specify an outfile, the output file is given the default name twmerge.out. If you want to specify a different name when you save the file, use File Save As.
Note - If you use the-l
listfile option, then all three input file names (ancestor, leftfile, and rightfile) must be directories. If you do not use the-l
listfile option, then any two input file names can be directories, but one of the three must be a simple file name. In this case, twmerge uses the file name to find a file with the same local name in each directory.
When used with the
-l
listfile option, outfile names the directory to be used when each merged output file is saved. Individual file names in the outfile directory are the same as the names listed in listfile.