Porting Central
Skip to main content

Porting Central

ezmrg: A Tool for Preparing Merges of Multiple Files

What ezmrg Is

Ezmrg is an ATK application that creates the data needed to merge the differences between one or more sets of two or three files. Ezmrg is an application executed from a command line which creates a file that can be edited to provide an EZ Merge window or, optionally, brings up an EZ Merge window directly (for help on using an EZ Merge window, click here ezmerge.)

Starting ezmrg

Ezmrg is invoked from a typescript or other command line as follows:

ezmrg [-w] [-o<outputfilename>] <master directory> [<maintenance directory>] <target directory> <file list>

Pop-up Menu Meanings

The pop-up menus are the same as documented for the EZ Merge window (see ezmerge.).

Warnings

The only way to save the files in the editable subwindows is through the menu items, Save Master File, Save Maintenance File, and Save Target File. Do not try to save a file in one of the subwindows using Save As and typing in the name of the file while you have an EZ Merge buffer in the window. If you do so, you will overwrite the file you were trying to save with the merge data.

The Restore Original button will not work if the original data within the difference in the target file contain insets. This is not a problem with source code since source code cannot contain insets, only for those types of files that can contain insets, like text files. Master->Target and Maint->Target buttons will work correctly even if insets are contained within the region that is copied.

Options

-w Brings up an EZ Merge window (see ezmerge for more information).
-o <output filename> Specifies the name of the output file.
<master directory> Directory containing the master copy of the files to be compared.
<maintenance directory> Directory containing the maintenance copy of the files to be compared. Optional, omit for two file merge.
<target directory> Directory containing the target copy of the files to be compared.
<file list> List of file names to be compared; may use wild cards. Only files in the file list that appear in all 3 directories will participate in the 3-way compare. Note that if the current working directory is not one of the directories participating in the ezmrg process, any wild card characters will need to be escaped with a "\" or the entire file list enclosed in quotes.
<master file> The name of the "master" file.
<maintenance file> The name of the "maintenance" file. This is optional. Omitting it will give a 2-way file merge.

<target file> The name of the "target" file.

How ezmrg Works

When two or three directories and a list of file names are specified, ezmrg will expand any wild cards in the list, and, for each file name that appears in all of the directories, will run gdiff3 (a 3-way compare program) that finds the differences between the three files[1]. This is done for each file name in the file list. A file containing those differences in an ATK datastream format is created. This file, when edited, will come up with an EZ Merge window that provides a way to merge the differences using a simple point and click interface. If -o and -w are not specified, the data is written to a file named ezmrg.mrg. If two or three files are specified, those files are run through gdiff3 and a file containing those results is created.

The -w option allows you to bring up the EZ Merge window directly without editing the resulting file. When -w is specified, a file is created only if the -o option is used, the assumption being that the resultant EZ Merge window is sufficient for merging the files or sets of files. If it is discovered after the window has come up that it is necessary to save the difference data created by ezmrg -w, the Save As menu item may be used.

Once the EZ Merge window has been brought up through ezmrg -w, it operates essentially the same way as an EZ Merge window brought up under ez by either editing a file created by ezmrg, or selecting the Merge Files or Merge File List menu item. In particular, you may Visit Buffers, Visit Files, etc., just as you would in ez. Buffers will also be checkpointed.

Customizing ezmrg

Ezmrg is an ATK application and, as such, it can be customized through your preferences file and a .ezmrginit file in your home directory.

Note: Since you probably want windows brought up using ezmrg -w to look and act like an ez window, it is recommended that your .ezmrginit file contain only the following lines:

include <your home directory path>/.atkinit

include $(ANDREWDIR)/lib/global.ezmrginit

include <your home directory path>/.ezinit

If you aet up your .ezmrginit file as recommended above, substitute ~/.ezinit for ~/.ezmrginit in the next section.

Proc Table Entries

The following procs can be added to your ~/.ezmrginit file and can be used to access the button functions through keystrokes. Placing the procs in your ~/.ezinit file will take effect when you bring up an EZ Merge window through ez. They will also take effect in your ezmrg -w window provided you include your ~/.ezinit file in your ~/.ezmrginit file.

filecmplistview-previous-difference- same as Prev Diff button

filecmplistview-next-difference- same as Next Diff button

filecmplistview-master-into-target- same as Master->Target button

filecmplistview-maint-into-target- same as Maint->Target button (3-way merge only)

filecmplistview-previous-compare- same as Prev Set button

filecmplistview-next-compare- same as Next Set button

filecmplistview-restore-original- same as Restore Original button

Example of binding one of the above procs to a key sequence in your ~/.ezmrginit file:

addkey filecmplistview-previous-difference ^X^P filecmplistview

The following procs are tied to menu items, but not keystroke sequences:

filecmplistview-save-targetBuffer- saves the Target buffer

The following procs are not tied to menu items, but are available if you find that you need the capability:

filecmplistview-save-maintBuffer- saves the Maintenance buffer

filecmplistview-save-masterBuffer- saves the Master buffer

Example of binding one of the above procs to a menu item in your ~/.ezmrginit file:

addmenu filecmplistview-save-maintBuffer "Ezmerge,Save Maint Buffer~15" filecmplistview

Preferences

Note: If you want consistency between EZ Merge windows brought up with ezmrg -w and the ez menu items, the preferences described below should have corresponding ez preferences with the same settings. The defaults are the same for both ez and ezmrg.

ezmrg.ShowBlankOnlyDiffs: yes

If no is specified, differences that are a result of whitespace (blanks, tabs, and newline characters) will not be shown when the EZ Merge window comes up. The Don't Treat Blanks as Equal menu item will appear.

ezmrg.ShowOnlyNonBlankDiffs: yes

If no is specified, differences that are not caused by white space (blanks, tabs, and newline characters) will not be shown. The Show Non Blank Only Diffs menu item will appear.

ezmrg.ShowTargetOnlyDiffs: yes

If no is specified, differences wherein the Master and the Maintenance files are the same are not shown. The Hide Target Only Diffs menu item will appear.

ezmrg.ShowMasterOnlyDiffs: yes

If no is specified, differences wherein the Target and the Maintenance files are the same are not shown. The Hide Master Only Diffs menu item will appear.

ezmrg.DiffListWidth: 40

Determines the percentage of total horizontal window width that the left-hand column (containing the list of differences, and buttons) should take up. The default is 40%, leaving 60% for the master/maint/target files in the right-hand column.

In addition to these specific preferences, other preferences such as ezmrg.Geometry, ezmrg.Bodyfont, ezmrg.BackgroundColor, etc., may be specified to tailor the window created by ezmrg. If you have preferences set that control the menubar or menu card order for ez, you may want to duplicate those preferences (such as PopupCardOrder: or MenubarCardOrder:) for ezmrg so that the menus appear in the same order for both ez and ezmrg.

Initialization

Because ezmrg is an ATK application you may also tailor it through a .ezmrginit file in your home directory. This file contains addmenu, addkey, and addfiletype commands that allow you to tailor the menu items, keystroke commands, and the way different file types are edited.

In general, the global.ezmrginit file (which is read if a .ezmrginit file is not found) will provide the basic tailoring that you will need. But if you do decide to create your own .ezmrginit file, you should include your ~/.atkinit file (if you have one) and your ~/.ezinit file as well as $(ANDREWDIR)/lib/global.ezmrginit. This will ensure that ezmrg windows will act essentially as if you were using ez, except, of course, for any special tailoring unique to ezmrg that you have done.

Error Messages

Error messages will appear in the typescript when running ezmrg. Error messages are generally self explanatory and every attempt has been made to word them such that the problem can be easily identified.

Recent Changes to ezmrg

Added -w option and 2-way merge.

Related Topic


1Techie Note: In the case of a two-way merge, the target file is also used as the maintenance file