Home

 

Examples

 

Technical

 TextMaestro

 

2003 TextMaestro Technologies

 

  Examples

  Example 1

  Example 2

  Example 3

  Example 4

  Example 5

  Example 6

  Example 7

  Example 8

  Example 9

  Example 10

  Example 11

  Example 12

  Example 13

  Example 14

  Example 15

  Example 16

  Example 17

  Example 18

  Example 19

  Example 20

  Example 21

 

 

Example 19: Diff and Merge

TextMaestro offers a simple yet powerful diff and merge facility. By nature, any diff logic is straight forward (commonly using Longest Common Subsequence (LCS) algorithm), while merge logic is complex. Even with a state of the art analysis, a merge algorithm may become fallacious, and thereby require manual intervention. With that in mind, TextMaestro leaves most of the merging on user's acceptance and offers a set of comfortable features to complete the mission. The diff-and-merge of TextMaestro is designed for the most complicated merging efforts that one might encounter. Yet its simplicity appeals to commonplace usage.

Quick Tips:

When you want to diff between two blocks of text in a hurry, simply put the two blocks on Input window and Output window and hit Alt+1. Alternatively, use this button from the File Diff Manager.

When you want to diff two files, simply select the two files in the main list, and hit Alt+2.  Alternatively, use this  button from the File Diff Manager.

When you want to do 3-way merge, simply select the three files in the main list, and hit Alt+3.  Alternatively, use this  button from the File Diff Manager.

Below is a simple demo on how to use 3-way merge feature.

Suppose we have three files, where one is the parent and the rest are descendants. Assume the following as the contents of the three files:

 

file-1.txt

file-2.txt

file-3.txt

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

1

12

123

1234

12345

123456

-<Yr 01>-

1234567

12345678

123456789

1234567890

2222222222

2222222222

 

1

12

123

1234

12345

123456

-<Year 2001>-

1234567

12345678

123456789

1234567890

 

1

12

123

33333333333

33333333333

1234

12345

123456

1234567

12345678

123456789

1234567890

3333333333

 

In addition, assume the following time-line on file modifications:

That is to say, File 2 and File 3 were modified independent of each other. They were however derived from File 1 and now we want to merge both sets of changes:

  • Changes between File 1 and 2, {1-2}

  • Changes between File 1 and 3, {1-3}

A merge task like this is called three-way merge. Here we show step by step how to accomplish it in TextMaestro.

 

(1) Launch the application.

(2) Drag the three files that we want to merge onto the main list as shown here.

(3) Select the three files, if they are not selected.

 

Then select Diff-n-Merge button (Alt+D) from the Session toolbar as shown below:

This will open the dialog below:

 

(4) Click on the 3-Way diff button. The 3-Way Diff pane will appear as shown below:

On the 3-Way Diff window, the first selected file is placed in the middle, second on the left, and third on the right, i.e., in the order of {2, 1, 3}. (See above).

(5) Click on Display palette for Master file button. The following will appear:

Now is the time to make a critical decision. We need to decide which of the three files to be loaded here. Often this decision depends on two things:

  • How to minimize the merge activities?

  • Which variant is of the highest priority?

Sometimes you may minimize the merging tasks by adopting a variant which has the most difference against the parent. But that might not be always the right thing to do. For example, your high priority variant may have very small changes, but taking the most 'noisy' variant as master copy may break your high priority one. Therefore, if you do have a high priority variant, take that as master copy and bring in all other variants' changes into it upon scrutiny.

When you do not know which variant is of the highest priority, it becomes tedious to decide which changes should be honored and which discarded. Such cases are commonly called conflicts. Almost always the user has to review the differences and resolve these conflicts one by one.

After initial review of the variants, we decided to load variant 1, i.e., file-1.txt into the Master File palette as shown below:

Let us now bring in the differences exposed on the right hand side of the 3-Way Diff window. We somehow concluded that line 4 and 5 are rightful candidates to be brought into Master File palette, while line 13 is not.

So, we drag and drop line 4 and 5 onto Master File palette in the right location, and it appears like this:

The icon implies that these lines came from variant 3.

Next, we bring in differences exposed on the left hand side of the 3-Way Diff window. Note, line 7 of left window should replace line 9 of Master File palette.

So, we hold down the control key, and drag line 7 from left window, and drop it onto Master File palette at line 9. Note, holding down the control key while dragging makes it an override mode. Otherwise, it is an addition mode.

This is how Master File palette appears:

The icon implies that this line came from variant 2, and it replaced the existing line in here.

If you were to edit a certain line here, simply double click on it and this dialog will appear, with a new line shown as an example:

When you add new lines in this edit pad, they will be added to the Master File palette. Hit OK. You will see the following:

The icon implies that this line came from the edit pad, manually added by the user.

At this stage, you may choose to save the palette to a file. Click on button and follow the steps. The file will be saved and listed on the main list under current selection.

That is it, unless you decide to check out the difference between one of the variants and the final copy.

If so, simply click the variant and the final copy, and hit on Quick Diff button from the File Diff Manager, or hit (Alt+2). Here is an example of a quick diff between variant 2 and the final copy.

  • You can use quick diff any time.

  • Every time you hit Quick Diff button, the last one is discarded and a new one is built. That way, your intermediate changes are captured.

  • However, make sure you save the Master File palette to propagate the changes into the diff. In other words, the diff engine picks up information from the file, not from Master File palette.

Quick Diff between File 2 and the merged file:

Comment:

  • Along with drag and drop, you also have choice of pop up menus by clicking on right mouse button on Diff panes, and also on Master File palette. They are sometimes helpful when you are working with extremely large file, and want to avoid tedious scrolling.

 

Popup menu from Diff windows:

 

Popup menu from Master File palette:

 

  • Use of Down and Up arrow to jump to variant differences is handy when you have very large file to work with. It avoids eye-balling and scrolling, and reduces chances of missing out difference instances.

  • Using Find text in Master palette button you can search for certain text in the Master palette. When you do not know the line number, but have some idea about the text, this becomes life-saver. You can perform similar search in the diff lists, simply by double-clicking on a line.

  • Double-clicking on diff list opens Find Text dialog. Double-clicking on Master File palette, opens Edit Master Palette dialog.

  • There are various bells-and-whistles on Master File palette, and we leave them for you to explore.

  • As part of the performance testing, we tried files of 250K lines and the responses were reasonable.

Top